Replying to a chat message has a different path

merge-requests/30/head
Bob Mottram 2022-02-08 10:52:03 +00:00
parent edb01af961
commit 51a666df39
4 changed files with 27 additions and 6 deletions

View File

@ -48,7 +48,7 @@ INVALID_CONTENT_STRINGS = (
'graph', 'showshare', 'category', 'showwanted', 'graph', 'showshare', 'category', 'showwanted',
'rmshare', 'rmwanted', 'repeatprivate', 'rmshare', 'rmwanted', 'repeatprivate',
'unrepeatprivate', 'replyto', 'unrepeatprivate', 'replyto',
'replyfollowers', 'replydm', 'editblogpost', 'replyfollowers', 'replydm', 'replychat', 'editblogpost',
'handle', 'blockdomain' 'handle', 'blockdomain'
) )

View File

@ -15932,8 +15932,11 @@ class PubServer(BaseHTTPRequestHandler):
# replying as a direct message, # replying as a direct message,
# for moderation posts or the dm timeline # for moderation posts or the dm timeline
if '?replydm=' in self.path: if '?replydm=' in self.path or '?replychat=' in self.path:
in_reply_to_url = self.path.split('?replydm=')[1] reply_type = 'replydm'
if '?replychat=' in self.path:
reply_type = 'replychat'
in_reply_to_url = self.path.split('?' + reply_type + '=')[1]
in_reply_to_url = urllib.parse.unquote_plus(in_reply_to_url) in_reply_to_url = urllib.parse.unquote_plus(in_reply_to_url)
if '?' in in_reply_to_url: if '?' in in_reply_to_url:
# multiple parameters # multiple parameters
@ -15970,9 +15973,10 @@ class PubServer(BaseHTTPRequestHandler):
share_description = \ share_description = \
share_description.replace('_', ' ') share_description.replace('_', ' ')
self.path = self.path.split('?replydm=')[0] + '/newdm' self.path = \
self.path.split('?' + reply_type + '=')[0] + '/newdm'
if self.server.debug: if self.server.debug:
print('DEBUG: replydm path ' + self.path) print('DEBUG: ' + reply_type + ' path ' + self.path)
# Edit a blog post # Edit a blog post
if authorized and \ if authorized and \

View File

@ -2654,6 +2654,19 @@ def reject_post_id(base_dir: str, nickname: str, domain: str,
reject_file.write('\n') reject_file.write('\n')
def is_chat_message(post_json_object: {}) -> bool:
"""Returns true if the given post is a chat message
Note that is_dm should be checked before calling this
"""
if post_json_object['type'] != 'Create':
return False
if not has_object_dict(post_json_object):
return False
if post_json_object['object']['type'] != 'ChatMessage':
return False
return True
def is_dm(post_json_object: {}) -> bool: def is_dm(post_json_object: {}) -> bool:
"""Returns true if the given post is a DM """Returns true if the given post is a DM
""" """

View File

@ -33,6 +33,7 @@ from utils import has_object_dict
from utils import update_announce_collection from utils import update_announce_collection
from utils import is_pgp_encrypted from utils import is_pgp_encrypted
from utils import is_dm from utils import is_dm
from utils import is_chat_message
from utils import reject_post_id from utils import reject_post_id
from utils import is_recent_post from utils import is_recent_post
from utils import get_config_param from utils import get_config_param
@ -445,10 +446,13 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str,
'" title="' + reply_to_this_post_str + '">\n' '" title="' + reply_to_this_post_str + '">\n'
else: else:
if is_dm(post_json_object): if is_dm(post_json_object):
reply_type = 'replydm'
if is_chat_message(post_json_object):
reply_type = 'replychat'
reply_str += \ reply_str += \
' ' + \ ' ' + \
'<a class="imageAnchor" href="/users/' + nickname + \ '<a class="imageAnchor" href="/users/' + nickname + \
'?replydm=' + reply_to_link + \ '?' + reply_type + '=' + reply_to_link + \
'?actor=' + post_json_object['actor'] + \ '?actor=' + post_json_object['actor'] + \
conversation_str + \ conversation_str + \
'" title="' + reply_to_this_post_str + '">\n' '" title="' + reply_to_this_post_str + '">\n'