mirror of https://gitlab.com/bashrc2/epicyon
Store history of edited posts
parent
4be7edd5f5
commit
a21c19eac1
14
inbox.py
14
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,
|
||||
|
|
12
utils.py
12
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)
|
||||
|
|
Loading…
Reference in New Issue