From 51a666df39ea4091fad71b998b291daf37675f97 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 8 Feb 2022 10:52:03 +0000 Subject: [PATCH] Replying to a chat message has a different path --- content.py | 2 +- daemon.py | 12 ++++++++---- utils.py | 13 +++++++++++++ webapp_post.py | 6 +++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/content.py b/content.py index aaa1545a3..5bebdb0de 100644 --- a/content.py +++ b/content.py @@ -48,7 +48,7 @@ INVALID_CONTENT_STRINGS = ( 'graph', 'showshare', 'category', 'showwanted', 'rmshare', 'rmwanted', 'repeatprivate', 'unrepeatprivate', 'replyto', - 'replyfollowers', 'replydm', 'editblogpost', + 'replyfollowers', 'replydm', 'replychat', 'editblogpost', 'handle', 'blockdomain' ) diff --git a/daemon.py b/daemon.py index c3a19c9ea..3ab138298 100644 --- a/daemon.py +++ b/daemon.py @@ -15932,8 +15932,11 @@ class PubServer(BaseHTTPRequestHandler): # replying as a direct message, # for moderation posts or the dm timeline - if '?replydm=' in self.path: - in_reply_to_url = self.path.split('?replydm=')[1] + if '?replydm=' in self.path or '?replychat=' in self.path: + 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) if '?' in in_reply_to_url: # multiple parameters @@ -15970,9 +15973,10 @@ class PubServer(BaseHTTPRequestHandler): share_description = \ share_description.replace('_', ' ') - self.path = self.path.split('?replydm=')[0] + '/newdm' + self.path = \ + self.path.split('?' + reply_type + '=')[0] + '/newdm' if self.server.debug: - print('DEBUG: replydm path ' + self.path) + print('DEBUG: ' + reply_type + ' path ' + self.path) # Edit a blog post if authorized and \ diff --git a/utils.py b/utils.py index c70c4fd28..b03a719df 100644 --- a/utils.py +++ b/utils.py @@ -2654,6 +2654,19 @@ def reject_post_id(base_dir: str, nickname: str, domain: str, 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: """Returns true if the given post is a DM """ diff --git a/webapp_post.py b/webapp_post.py index 01b1c1675..c645a30fe 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -33,6 +33,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_chat_message from utils import reject_post_id from utils import is_recent_post 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' else: if is_dm(post_json_object): + reply_type = 'replydm' + if is_chat_message(post_json_object): + reply_type = 'replychat' reply_str += \ ' ' + \ '\n'