diff --git a/inbox.py b/inbox.py index e7a4f2500..dd4127794 100644 --- a/inbox.py +++ b/inbox.py @@ -1038,6 +1038,17 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {}, print('EDITPOST: actors do not match ' + post_json_object['actor'] + ' != ' + message_json['actor']) return False + # save the edit history to file + post_history_filename = post_filename.replace('.json', '') + '.edits' + post_history_json = {} + if os.path.isfile(post_history_filename): + post_history_json = load_json(post_history_filename, 1) + if post_json_object['object'].get('updated'): + published_str = post_json_object['object']['updated'] + else: + published_str = post_json_object['object']['published'] + post_history_json[published_str] = post_json_object + save_json(post_history_json, post_history_filename) # Change Update to Create message_json['type'] = 'Create' save_json(message_json, post_filename) @@ -1080,8 +1091,7 @@ def _receive_edit_to_post(recent_posts_cache: {}, message_json: {}, session, cached_webfingers, person_cache, nickname, domain, port, message_json, None, True, allow_deletion, - http_prefix, __version__, - 'inbox', + http_prefix, __version__, 'inbox', yt_replace_domain, twitter_replacement_domain, show_published_date_only, diff --git a/utils.py b/utils.py index ffc1d721c..3ef8dd340 100644 --- a/utils.py +++ b/utils.py @@ -1831,7 +1831,9 @@ def delete_post(base_dir: str, http_prefix: str, # remove any attachment _remove_attachment(base_dir, http_prefix, domain, post_json_object) - extensions = ('votes', 'arrived', 'muted', 'tts', 'reject', 'mitm') + extensions = ( + 'votes', 'arrived', 'muted', 'tts', 'reject', 'mitm', 'edits' + ) for ext in extensions: ext_filename = post_filename + '.' + ext if os.path.isfile(ext_filename): @@ -1840,6 +1842,14 @@ def delete_post(base_dir: str, http_prefix: str, except OSError: print('EX: delete_post unable to remove ext ' + str(ext_filename)) + elif post_filename.endswith('.json'): + ext_filename = post_filename.replace('.json', '') + '.' + ext + if os.path.isfile(ext_filename): + try: + os.remove(ext_filename) + except OSError: + print('EX: delete_post unable to remove ext ' + + str(ext_filename)) # remove cached html version of the post delete_cached_html(base_dir, nickname, domain, post_json_object)