'context' is sometimes used to mean the same thing as 'conversation'

This does not appear to be part of the AP spec, but is used in the wild
merge-requests/30/head
Bob Mottram 2023-01-09 11:38:05 +00:00
parent 40ba283755
commit 86eb346cf7
10 changed files with 36 additions and 8 deletions

View File

@ -910,6 +910,9 @@ def mute_post(base_dir: str, nickname: str, domain: str, port: int,
if post_json_obj.get('conversation'):
mute_conversation(base_dir, nickname, domain,
post_json_obj['conversation'])
elif post_json_obj.get('context'):
mute_conversation(base_dir, nickname, domain,
post_json_obj['context'])
# does this post have ignores on it from differenent actors?
if not post_json_obj.get('ignores'):
@ -1048,6 +1051,9 @@ def unmute_post(base_dir: str, nickname: str, domain: str, port: int,
if post_json_obj.get('conversation'):
unmute_conversation(base_dir, nickname, domain,
post_json_obj['conversation'])
elif post_json_obj.get('context'):
unmute_conversation(base_dir, nickname, domain,
post_json_obj['context'])
if post_json_obj.get('ignores'):
domain_full = get_full_domain(domain, port)

View File

@ -25,14 +25,18 @@ def _get_conversation_filename(base_dir: str, nickname: str, domain: str,
"""
if not has_object_dict(post_json_object):
return None
if not post_json_object['object'].get('conversation'):
if not post_json_object['object'].get('conversation') and \
not post_json_object['object'].get('context'):
return None
if not post_json_object['object'].get('id'):
return None
conversation_dir = acct_dir(base_dir, nickname, domain) + '/conversation'
if not os.path.isdir(conversation_dir):
os.mkdir(conversation_dir)
conversation_id = post_json_object['object']['conversation']
if post_json_object['object'].get('conversation'):
conversation_id = post_json_object['object']['conversation']
else:
conversation_id = post_json_object['object']['context']
conversation_id = conversation_id.replace('/', '#')
return conversation_dir + '/' + conversation_id

View File

@ -1825,6 +1825,9 @@ def run_desktop_client(base_dir: str, proxy_type: str, http_prefix: str,
if post_json_object['object'].get('conversation'):
conversation_id = \
post_json_object['object']['conversation']
elif post_json_object['object'].get('context'):
conversation_id = \
post_json_object['object']['context']
session_reply = create_session(proxy_type)
_desktop_reply_to_post(session_reply, post_id,
base_dir, nickname,

View File

@ -911,6 +911,7 @@ def _dav_store_event(base_dir: str, nickname: str, domain: str,
"object": {
"id": post_id,
"conversation": post_id,
"context": post_id,
"type": "Note",
"summary": None,
"inReplyTo": None,

View File

@ -3993,6 +3993,8 @@ def _create_reply_notification_file(base_dir: str, nickname: str, domain: str,
conversation_id = None
if post_json_object['object'].get('conversation'):
conversation_id = post_json_object['object']['conversation']
elif post_json_object['object'].get('context'):
conversation_id = post_json_object['object']['context']
if not post_json_object['object'].get('inReplyTo'):
return is_reply_to_muted_post

View File

@ -1126,6 +1126,7 @@ def _create_post_s2s(base_dir: str, nickname: str, domain: str, port: int,
'object': {
'id': new_post_id,
'conversation': conversation_id,
'context': conversation_id,
'type': post_object_type,
'summary': summary,
'inReplyTo': in_reply_to,
@ -1193,6 +1194,7 @@ def _create_post_c2s(base_dir: str, nickname: str, domain: str, port: int,
"@context": post_context,
'id': new_post_id,
'conversation': conversation_id,
'context': conversation_id,
'type': post_object_type,
'summary': summary,
'inReplyTo': in_reply_to,

View File

@ -2032,13 +2032,17 @@ def _delete_conversation_post(base_dir: str, nickname: str, domain: str,
"""
if not has_object_dict(post_json_object):
return False
if not post_json_object['object'].get('conversation'):
if not post_json_object['object'].get('conversation') and \
not post_json_object['object'].get('context'):
return False
if not post_json_object['object'].get('id'):
return False
conversation_dir = \
acct_dir(base_dir, nickname, domain) + '/conversation'
conversation_id = post_json_object['object']['conversation']
if post_json_object['object'].get('conversation'):
conversation_id = post_json_object['object']['conversation']
else:
conversation_id = post_json_object['object']['context']
conversation_id = conversation_id.replace('/', '#')
post_id = post_json_object['object']['id']
conversation_filename = conversation_dir + '/' + conversation_id

View File

@ -150,6 +150,7 @@ def convert_video_to_note(base_dir: str, nickname: str, domain: str,
'object': {
'id': new_post_id,
'conversation': conversation_id,
'context': conversation_id,
'type': 'Note',
'summary': None,
'inReplyTo': None,

View File

@ -258,6 +258,8 @@ def html_new_post(edit_post_params: {},
return ''
if edited_post_json['object'].get('conversation'):
conversation_id = edited_post_json['object']['conversation']
elif edited_post_json['object'].get('context'):
conversation_id = edited_post_json['object']['context']
if edit_post_params.get('replyTo'):
in_reply_to = edit_post_params['replyTo']
if edit_post_params['scope'] == 'dm':

View File

@ -2177,10 +2177,13 @@ def individual_post_as_html(signing_priv_key_pem: str,
comments_enabled = False
conversation_id = None
if isinstance(post_json_object['object'], dict) and \
'conversation' in post_json_object['object']:
if post_json_object['object']['conversation']:
conversation_id = post_json_object['object']['conversation']
if isinstance(post_json_object['object'], dict):
if 'conversation' in post_json_object['object']:
if post_json_object['object']['conversation']:
conversation_id = post_json_object['object']['conversation']
elif 'context' in post_json_object['object']:
if post_json_object['object']['context']:
conversation_id = post_json_object['object']['context']
public_reply = False
unlisted_reply = False