diff --git a/daemon.py b/daemon.py index 1ab471da6..7d032b70a 100644 --- a/daemon.py +++ b/daemon.py @@ -16799,6 +16799,26 @@ class PubServer(BaseHTTPRequestHandler): if self.server.debug: print('DEBUG: replyto path ' + self.path) + # unlisted reply + if '?replyunlisted=' in self.path: + in_reply_to_url = self.path.split('?replyunlisted=')[1] + if '?' in in_reply_to_url: + mentions_list = in_reply_to_url.split('?') + for m in mentions_list: + if m.startswith('mention='): + reply_handle = m.replace('mention=', '') + if reply_handle not in reply_to_list: + reply_to_list.append(reply_handle) + if m.startswith('page='): + reply_page_str = m.replace('page=', '') + if reply_page_str.isdigit(): + reply_page_number = int(reply_page_str) + in_reply_to_url = mentions_list[0] + self.path = \ + self.path.split('?replyunlisted=')[0] + '/newunlisted' + if self.server.debug: + print('DEBUG: replyunlisted path ' + self.path) + # reply to followers if '?replyfollowers=' in self.path: in_reply_to_url = self.path.split('?replyfollowers=')[1] diff --git a/utils.py b/utils.py index 7a866dde2..7f46917b8 100644 --- a/utils.py +++ b/utils.py @@ -2023,6 +2023,32 @@ def is_public_post(post_json_object: {}) -> bool: return False +def is_unlisted_post(post_json_object: {}) -> bool: + """Returns true if the given post is unlisted + """ + if not post_json_object.get('type'): + return False + if post_json_object['type'] != 'Create': + return False + if not has_object_dict(post_json_object): + return False + if not post_json_object['object'].get('to'): + return False + if not post_json_object['object'].get('cc'): + return False + has_followers = False + for recipient in post_json_object['object']['to']: + if recipient.endswith('/followers'): + has_followers = True + break + if not has_followers: + return False + for recipient in post_json_object['object']['cc']: + if recipient.endswith('#Public'): + return True + return False + + def copytree(src: str, dst: str, symlinks: str = False, ignore: bool = None): """Copy a directory """ diff --git a/webapp_create_post.py b/webapp_create_post.py index b764f262d..4dff64b43 100644 --- a/webapp_create_post.py +++ b/webapp_create_post.py @@ -692,7 +692,7 @@ def html_new_post(css_cache: {}, media_instance: bool, translate: {}, if inReplyTo: dropdown_new_post_suffix += '?replyto=' + inReplyTo dropdown_new_blog_suffix += '?replyto=' + inReplyTo - dropdown_unlisted_suffix += '?replyto=' + inReplyTo + dropdown_unlisted_suffix += '?replyunlisted=' + inReplyTo dropdown_followers_suffix += '?replyfollowers=' + inReplyTo if reply_is_chat: dropdown_dm_suffix += '?replychat=' + inReplyTo diff --git a/webapp_post.py b/webapp_post.py index 59f40e1b8..5100eeb09 100644 --- a/webapp_post.py +++ b/webapp_post.py @@ -57,6 +57,7 @@ from utils import get_nickname_from_actor from utils import get_domain_from_actor from utils import acct_dir from utils import local_actor_url +from utils import is_unlisted_post from content import limit_repeated_words from content import replace_emoji_from_tags from content import html_replace_quote_marks @@ -389,7 +390,7 @@ def _get_avatar_image_html(showAvatarOptions: bool, def _get_reply_icon_html(base_dir: str, nickname: str, domain: str, - is_public_repeat: bool, + is_public_reply: bool, is_unlisted_reply: bool, show_icons: bool, comments_enabled: bool, post_json_object: {}, page_number_param: str, translate: {}, system_language: str, @@ -439,13 +440,20 @@ def _get_reply_icon_html(base_dir: str, nickname: str, domain: str, conversation_str = '' if conversation_id: conversation_str = '?conversationId=' + conversation_id - if is_public_repeat: + if is_public_reply: reply_str += \ ' \n' + elif is_unlisted_reply: + reply_str += \ + ' \n' else: if is_dm(post_json_object): reply_type = 'replydm' @@ -1698,10 +1706,14 @@ def individual_post_as_html(signing_priv_key_pem: str, conversation_id = post_json_object['object']['conversation'] public_reply = False + unlisted_reply = False if is_public_post(post_json_object): public_reply = True + if is_unlisted_post(post_json_object): + public_reply = False + unlisted_reply = True reply_str = _get_reply_icon_html(base_dir, nickname, domain, - public_reply, + public_reply, unlisted_reply, show_icons, comments_enabled, post_json_object, page_number_param, translate, system_language,