Support for receiving ChatMessage activities

Equivalent to a Note DM
main
Bob Mottram 2022-02-08 10:33:13 +00:00
parent 4daec86f2a
commit edb01af961
3 changed files with 14 additions and 10 deletions

View File

@ -408,7 +408,7 @@ def post_message_to_outbox(session, translate: {},
# The following activity types get added to the index files
indexed_activities = (
'Create', 'Question', 'Note', 'EncryptedMessage', 'Article',
'Patch', 'Announce'
'Patch', 'Announce', 'ChatMessage'
)
if message_json['type'] in indexed_activities:
indexes = [outbox_name, "inbox"]

View File

@ -484,9 +484,9 @@ def _is_public_feed_post(item: {}, person_posts: {}, debug: bool) -> bool:
this_item = item['object']
# check that this is a public post
# #Public should appear in the "to" list
itemIsNote = False
item_is_note = False
if item['type'] == 'Note' or item['type'] == 'Page':
itemIsNote = True
item_is_note = True
if isinstance(this_item, dict):
if this_item.get('to'):
@ -497,7 +497,7 @@ def _is_public_feed_post(item: {}, person_posts: {}, debug: bool) -> bool:
break
if not is_public:
return False
elif isinstance(this_item, str) or itemIsNote:
elif isinstance(this_item, str) or item_is_note:
if item.get('to'):
is_public = False
for recipient in item['to']:
@ -3561,6 +3561,7 @@ def is_image_media(session, base_dir: str, http_prefix: str,
if post_json_object['object']['type'] != 'Note' and \
post_json_object['object']['type'] != 'Page' and \
post_json_object['object']['type'] != 'Event' and \
post_json_object['object']['type'] != 'ChatMessage' and \
post_json_object['object']['type'] != 'Article':
return False
if not post_json_object['object'].get('attachment'):
@ -3583,6 +3584,7 @@ def _add_post_string_to_timeline(post_str: str, boxname: str,
# must be a recognized ActivityPub type
if ('"Note"' in post_str or
'"EncryptedMessage"' in post_str or
'"ChatMessage"' in post_str or
'"Event"' in post_str or
'"Article"' in post_str or
'"Patch"' in post_str or

View File

@ -2661,12 +2661,13 @@ def is_dm(post_json_object: {}) -> bool:
return False
if not has_object_dict(post_json_object):
return False
if post_json_object['object']['type'] != 'Note' and \
post_json_object['object']['type'] != 'Page' and \
post_json_object['object']['type'] != 'Patch' and \
post_json_object['object']['type'] != 'EncryptedMessage' and \
post_json_object['object']['type'] != 'Article':
return False
if post_json_object['object']['type'] != 'ChatMessage':
if post_json_object['object']['type'] != 'Note' and \
post_json_object['object']['type'] != 'Page' and \
post_json_object['object']['type'] != 'Patch' and \
post_json_object['object']['type'] != 'EncryptedMessage' and \
post_json_object['object']['type'] != 'Article':
return False
if post_json_object['object'].get('moderationStatus'):
return False
fields = ('to', 'cc')
@ -2693,6 +2694,7 @@ def is_reply(post_json_object: {}, actor: str) -> bool:
if post_json_object['object']['type'] != 'Note' and \
post_json_object['object']['type'] != 'Page' and \
post_json_object['object']['type'] != 'EncryptedMessage' and \
post_json_object['object']['type'] != 'ChatMessage' and \
post_json_object['object']['type'] != 'Article':
return False
if post_json_object['object'].get('inReplyTo'):