From 5e8cb2673e85ece1a80fa5944c63c3ad7e0220e6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 20 Sep 2023 18:42:09 +0100 Subject: [PATCH] Replies on public posts can default to unlisted --- daemon.py | 11 +++++++++-- epicyon.py | 16 +++++++++++++++- tests.py | 16 ++++++++++++---- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/daemon.py b/daemon.py index 58c2693f1..d6d220f47 100644 --- a/daemon.py +++ b/daemon.py @@ -20223,7 +20223,11 @@ class PubServer(BaseHTTPRequestHandler): # if m.startswith('actor='): # replytoActor = m.replace('actor=', '') in_reply_to_url = mentions_list[0] - self.path = self.path.split('?replyto=')[0] + '/newpost' + if not self.path.public_replies_unlisted: + self.path = self.path.split('?replyto=')[0] + '/newpost' + else: + self.path = \ + self.path.split('?replyto=')[0] + '/newunlisted' if self.server.debug: print('DEBUG: replyto path ' + self.path) @@ -23863,7 +23867,8 @@ def load_tokens(base_dir: str, tokens_dict: {}, tokens_lookup: {}) -> None: break -def run_daemon(max_shares_on_profile: int, +def run_daemon(public_replies_unlisted: int, + max_shares_on_profile: int, max_hashtags: int, map_format: str, clacks: str, @@ -24001,6 +24006,8 @@ def run_daemon(max_shares_on_profile: int, else: httpd.clacks = 'GNU Natalie Nguyen' + httpd.public_replies_unlisted = public_replies_unlisted + # load a list of dogwhistle words dogwhistles_filename = base_dir + '/accounts/dogwhistles.txt' if not os.path.isfile(dogwhistles_filename): diff --git a/epicyon.py b/epicyon.py index 3facef6cb..72f069f06 100644 --- a/epicyon.py +++ b/epicyon.py @@ -449,6 +449,12 @@ def _command_options() -> None: type=str2bool, nargs='?', const=True, default=False, help="Caldav") + parser.add_argument("--public_replies_unlisted", + dest='public_replies_unlisted', + type=str2bool, nargs='?', + const=True, default=False, + help="Whether replies to public posts " + + "should be unlisted") parser.add_argument("--show_publish_as_icon", dest='show_publish_as_icon', type=str2bool, nargs='?', @@ -838,6 +844,13 @@ def _command_options() -> None: print("--path option should not end with '/'") sys.exit() + if not argb.public_replies_unlisted: + pub_replies_unlisted = \ + get_config_param(base_dir, 'publicRepliesUnlisted') + if pub_replies_unlisted is not None: + if isinstance(pub_replies_unlisted, bool): + argb.public_replies_unlisted = pub_replies_unlisted + if argb.setadmin: set_config_param(base_dir, 'admin', argb.setadmin) sys.exit() @@ -3912,7 +3925,8 @@ def _command_options() -> None: if __name__ == "__main__": argb2, opt2 = _command_options() print('allowdeletion: ' + str(argb2.allowdeletion)) - run_daemon(argb2.max_shares_on_profile, + run_daemon(argb2.public_replies_unlisted, + argb2.max_shares_on_profile, argb2.max_hashtags, argb2.mapFormat, argb2.clacks, diff --git a/tests.py b/tests.py index c4680f230..643996344 100644 --- a/tests.py +++ b/tests.py @@ -873,8 +873,10 @@ def create_server_alice(path: str, domain: str, port: int, map_format = 'gpx' max_hashtags = 20 max_shares_on_profile = 8 + public_replies_unlisted = False print('Server running: Alice') - run_daemon(max_shares_on_profile, max_hashtags, map_format, + run_daemon(public_replies_unlisted, + max_shares_on_profile, max_hashtags, map_format, clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed, @@ -1049,8 +1051,10 @@ def create_server_bob(path: str, domain: str, port: int, map_format = 'gpx' max_hashtags = 20 max_shares_on_profile = 8 + public_replies_unlisted = False print('Server running: Bob') - run_daemon(max_shares_on_profile, max_hashtags, map_format, + run_daemon(public_replies_unlisted, + max_shares_on_profile, max_hashtags, map_format, clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed, @@ -1136,8 +1140,10 @@ def create_server_eve(path: str, domain: str, port: int, federation_list: [], map_format = 'gpx' max_hashtags = 20 max_shares_on_profile = 8 + public_replies_unlisted = False print('Server running: Eve') - run_daemon(max_shares_on_profile, max_hashtags, map_format, + run_daemon(public_replies_unlisted, + max_shares_on_profile, max_hashtags, map_format, clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed, @@ -1225,8 +1231,10 @@ def create_server_group(path: str, domain: str, port: int, map_format = 'gpx' max_hashtags = 20 max_shares_on_profile = 8 + public_replies_unlisted = False print('Server running: Group') - run_daemon(max_shares_on_profile, max_hashtags, map_format, + run_daemon(public_replies_unlisted, + max_shares_on_profile, max_hashtags, map_format, clacks, preferred_podcast_formats, check_actor_timeout, crawlers_allowed,