From 2a12ab2bc7975e16c4a059f845acfd1696326919 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 4 Feb 2024 13:18:08 +0000 Subject: [PATCH] Tidying --- posts.py | 2 ++ webapp_profile.py | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/posts.py b/posts.py index e56b80154..ca85048dc 100644 --- a/posts.py +++ b/posts.py @@ -231,6 +231,8 @@ def parse_user_feed(signing_priv_key_pem: str, session, feed_url: str, as_header: {}, project_version: str, http_prefix: str, origin_domain: str, debug: bool, depth: int = 0) -> []: + """Returns a feed of posts for an account url + """ if depth > 10: if debug: print('Maximum search depth reached') diff --git a/webapp_profile.py b/webapp_profile.py index 3cb1373f1..a34119d0e 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -10,6 +10,7 @@ __module_group__ = "Web Interface" import os from pprint import pprint from webfinger import webfinger_handle +from utils import get_attributed_to from utils import get_url_from_post from utils import get_memorials from utils import text_in_file @@ -175,11 +176,12 @@ def _valid_profile_preview_post(post_json_object: {}, if has_object_dict(post_json_object): # convert attributedTo actor back to id if post_json_object['object'].get('attributedTo'): - if isinstance(post_json_object['object']['attributedTo'], - dict): - if post_json_object['object']['attributedTo'].get('id'): - post_json_object['object']['attributedTo'] = \ - post_json_object['object']['attributedTo']['id'] + attrib_field = post_json_object['object']['attributedTo'] + if attrib_field: + if isinstance(attrib_field, dict): + attrib = get_attributed_to(attrib_field) + if attrib: + post_json_object['object']['attributedTo'] = attrib if not is_announced_feed_item: actor_url = get_actor_from_post(post_json_object) if actor_url != person_url and \