From 4d968264f2e635b58765799982b5135a194f07a4 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 8 Sep 2019 11:34:00 +0200 Subject: [PATCH] Better default post visibility --- blueprints/admin.py | 8 ++++++++ templates/new.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/blueprints/admin.py b/blueprints/admin.py index 6d51602..e8a08e8 100644 --- a/blueprints/admin.py +++ b/blueprints/admin.py @@ -296,6 +296,7 @@ def admin_new() -> _Response: content = "" thread: List[Any] = [] print(request.args) + default_visibility = None # ap.Visibility.PUBLIC if request.args.get("reply"): data = DB.activities.find_one({"activity.object.id": request.args.get("reply")}) if data: @@ -308,10 +309,16 @@ def admin_new() -> _Response: ), ) reply = ap.parse_activity(data["activity"]["object"]) + # Fetch the post visibility, in case it's follower only + default_visibility = ap.get_visibility(reply) + # If it's public, we default the reply to unlisted + if default_visibility == ap.Visibility.PUBLIC: + default_visibility = ap.Visibility.UNLISTED reply_id = reply.id if reply.ACTIVITY_TYPE == ap.ActivityType.CREATE: reply_id = reply.get_object().id + actor = reply.get_actor() domain = urlparse(actor.id).netloc # FIXME(tsileo): if reply of reply, fetch all participants @@ -324,6 +331,7 @@ def admin_new() -> _Response: reply=reply_id, content=content, thread=thread, + default_visibility=default_visibility, visibility=ap.Visibility, emojis=config.EMOJIS.split(" "), custom_emojis={ diff --git a/templates/new.html b/templates/new.html index 8755170..1b9a63c 100644 --- a/templates/new.html +++ b/templates/new.html @@ -25,7 +25,7 @@ {% if reply %}{% endif %}