Edit reminder

main
Bob Mottram 2022-12-09 10:18:26 +00:00
parent d3fe3110e9
commit 640ffec1c3
2 changed files with 38 additions and 0 deletions

View File

@ -2046,6 +2046,28 @@ def is_dm(post_json_object: {}) -> bool:
return True
def is_reminder(post_json_object: {}) -> bool:
"""Returns true if the given post is a reminder
"""
if not is_dm(post_json_object):
return False
if not post_json_object['object'].get('to'):
return False
if not post_json_object['object'].get('attributedTo'):
return False
if not post_json_object['object'].get('tag'):
return False
if len(post_json_object['object']['to']) != 1:
return False
if post_json_object['object']['to'][0] != \
post_json_object['object']['attributedTo']:
return False
for tag in post_json_object['object']['tag']:
if tag['type'] == 'Event':
return True
return False
def _is_remote_dm(domain_full: str, post_json_object: {}) -> bool:
"""Is the given post a DM from a different domain?
"""

View File

@ -40,6 +40,7 @@ from utils import has_object_dict
from utils import update_announce_collection
from utils import is_pgp_encrypted
from utils import is_dm
from utils import is_reminder
from utils import is_chat_message
from utils import reject_post_id
from utils import is_recent_post
@ -612,6 +613,21 @@ def _get_edit_icon_html(base_dir: str, nickname: str, domain_full: str,
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
' |" src="/icons/edit.png"/></a>\n'
elif is_reminder(post_json_object):
# Edit a reminder
edit_post_str = 'Edit reminder'
if translate.get(edit_post_str):
edit_post_str = translate[edit_post_str]
edit_str += \
' ' + \
'<a class="imageAnchor" href="/users/' + \
nickname + '?postedit=' + \
post_id.split('/statuses/')[1] + ';scope=reminder' + \
';actor=' + actor_nickname + reply_to + \
'" title="' + edit_post_str + '" tabindex="10">' + \
'<img loading="lazy" decoding="async" title="' + \
edit_post_str + '" alt="' + edit_post_str + \
' |" src="/icons/edit.png"/></a>\n'
elif is_dm(post_json_object):
# Edit a DM
edit_post_str = 'Edit post'