Allow DMs if they are votes on a question

merge-requests/30/head
Bob Mottram 2023-01-12 11:30:23 +00:00
parent 212bdacdb3
commit a06bb9217c
1 changed files with 42 additions and 26 deletions

View File

@ -3821,6 +3821,22 @@ def _is_valid_dm(base_dir: str, nickname: str, domain: str, port: int,
# Not sending to yourself # Not sending to yourself
if not sending_to_self: if not sending_to_self:
obj_has_dict = has_object_dict(post_json_object)
# is this a vote on a question?
if obj_has_dict:
if post_json_object['object'].get("name") and \
post_json_object['object'].get("inReplyTo"):
# make the content the same as the vote answer
post_json_object['object']['content'] = \
post_json_object['object']['name']
# remove any other content
if post_json_object['object'].get("contentMap"):
del post_json_object['object']['contentMap']
# remove any summary / cw
post_json_object['object']['summary'] = None
if post_json_object['object'].get("summaryMap"):
del post_json_object['object']['summaryMap']
return True
# get the handle of the DM sender # get the handle of the DM sender
send_h = sending_actor_nickname + '@' + sending_actor_domain send_h = sending_actor_nickname + '@' + sending_actor_domain
# check the follow # check the follow
@ -3835,8 +3851,8 @@ def _is_valid_dm(base_dir: str, nickname: str, domain: str, port: int,
# don't send bounces back to # don't send bounces back to
# replies to bounce messages # replies to bounce messages
obj = post_json_object['object'] obj = post_json_object['object']
if isinstance(obj, dict): if obj_has_dict and \
if not obj.get('inReplyTo'): not obj.get('inReplyTo'):
bounced_id = \ bounced_id = \
remove_id_ending(post_json_object['id']) remove_id_ending(post_json_object['id'])
bounce_chat = False bounce_chat = False