From 968836a40f59bc9e02a24faea1148ebf4362ec84 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 9 Apr 2022 17:13:02 +0100 Subject: [PATCH] Check that incoming edited posts have changed --- inbox.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/inbox.py b/inbox.py index dd4127794..8fc5b911e 100644 --- a/inbox.py +++ b/inbox.py @@ -1033,11 +1033,28 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {}, return False if not post_json_object.get('actor'): return False + if not has_object_dict(post_json_object): + return False + if not post_json_object['object'].get('content'): + return False + if not message_json['object'].get('content'): + return False # does the actor match? if post_json_object['actor'] != message_json['actor']: print('EDITPOST: actors do not match ' + post_json_object['actor'] + ' != ' + message_json['actor']) return False + # has the content changed? + if post_json_object['object']['content'] == \ + message_json['object']['content']: + # same content + if 'summary' in post_json_object['object'] and \ + 'summary' in message_json['object']: + if post_json_object['object']['summary'] == \ + message_json['object']['summary']: + return False + else: + return False # save the edit history to file post_history_filename = post_filename.replace('.json', '') + '.edits' post_history_json = {}