diff --git a/inbox.py b/inbox.py index 78bcbb968..590bec2ca 100644 --- a/inbox.py +++ b/inbox.py @@ -118,6 +118,7 @@ from threads import begin_thread from reading import store_book_events from inbox_receive import inbox_update_index from inbox_receive import receive_edit_to_post +from inbox_receive import receive_actor_status from inbox_receive import receive_like from inbox_receive import receive_reaction from inbox_receive import receive_zot_reaction @@ -320,7 +321,7 @@ def inbox_message_has_params(message_json: {}) -> bool: allowed_without_to_param = ['Like', 'EmojiReact', 'Follow', 'Join', 'Request', 'Accept', 'Capability', 'Undo', - 'Move'] + 'Move', 'sm:ActorStatus', 'ActorStatus'] if message_json['type'] not in allowed_without_to_param: return False return True @@ -343,7 +344,7 @@ def inbox_permitted_message(domain: str, message_json: {}, always_allowed_types = ( 'Follow', 'Join', 'Like', 'EmojiReact', 'Delete', 'Announce', 'Move', - 'QuoteRequest' + 'QuoteRequest', 'sm:ActorStatus', 'ActorStatus' ) if message_json['type'] not in always_allowed_types: if not has_object_dict(message_json): @@ -1857,6 +1858,16 @@ def _inbox_after_initial(server, inbox_start_time, handle_name = handle.split('@')[0] + if receive_actor_status(base_dir, person_cache, message_json, + debug): + if debug: + print('DEBUG: ActorStatus from ' + actor) + fitness_performance(inbox_start_time, server.fitness, + 'INBOX', '_receive_actor_status', + debug) + inbox_start_time = time.time() + return False + if receive_like(recent_posts_cache, session, handle, base_dir, http_prefix, diff --git a/inbox_receive.py b/inbox_receive.py index 251ba2e3c..a4bb1ec93 100644 --- a/inbox_receive.py +++ b/inbox_receive.py @@ -52,6 +52,7 @@ from utils import get_url_from_post from utils import remove_html from utils import get_full_domain from utils import get_user_paths +from cache import get_person_from_cache from cache import get_actor_public_key_from_id from cache import store_person_in_cache from cache import get_person_pub_key @@ -1085,6 +1086,39 @@ def receive_like(recent_posts_cache: {}, return True +def receive_actor_status(base_dir: str, person_cache: {}, message_json: {}, + debug: bool) -> bool: + """Receives an sm:ActorStatus activity within the POST section + of HTTPServer + https://codeberg.org/fediverse/fep/src/branch/main/fep/82f6/fep-82f6.md + """ + if message_json['type'] not in ('sm:ActorStatus', 'ActorStatus'): + return False + if 'content' in message_json: + return False + if not isinstance(message_json['content'], str): + return False + if not has_actor(message_json, debug): + return False + actor_url = get_actor_from_post(message_json) + if not actor_url: + return False + if not has_users_path(actor_url): + if debug: + print('DEBUG: "users" or "profile" missing from actor status in ' + + str(message_json)) + return False + actor_json = get_person_from_cache(base_dir, actor_url, person_cache) + if not actor_json: + return False + actor_json['sm:status'] = message_json + allow_write_to_file = True + store_person_in_cache(base_dir, actor_url, + actor_json, person_cache, + allow_write_to_file) + return True + + def receive_reaction(recent_posts_cache: {}, session, handle: str, base_dir: str, http_prefix: str, domain: str, port: int, diff --git a/outbox.py b/outbox.py index b232f3b40..62ad4df8f 100644 --- a/outbox.py +++ b/outbox.py @@ -497,7 +497,7 @@ def post_message_to_outbox(session, translate: {}, permitted_outbox_types = ( 'Create', 'Announce', 'Like', 'EmojiReact', 'Follow', 'Undo', 'Update', 'Add', 'Remove', 'Block', 'Delete', 'Skill', 'Ignore', - 'Move', 'Edition' + 'Move', 'Edition', 'sm:ActorStatus', 'ActorStatus' ) if message_json['type'] not in permitted_outbox_types: if debug: