From a273f2654996ae60fbca92f017c8ba9b702b24f2 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Wed, 30 Nov 2022 17:49:36 +0100 Subject: [PATCH] Only show local delete for local replies --- app/ap_object.py | 10 ++++++++++ app/boxes.py | 6 +----- app/templates/utils.html | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/ap_object.py b/app/ap_object.py index 52061b8..77586aa 100644 --- a/app/ap_object.py +++ b/app/ap_object.py @@ -12,6 +12,7 @@ from app import activitypub as ap from app.actor import LOCAL_ACTOR from app.actor import Actor from app.actor import RemoteActor +from app.config import ID from app.media import proxied_media_url from app.utils.datetime import now from app.utils.datetime import parse_isoformat @@ -212,6 +213,15 @@ class Object: def in_reply_to(self) -> str | None: return self.ap_object.get("inReplyTo") + @property + def is_local_reply(self) -> bool: + if not self.in_reply_to: + return False + + return bool( + self.in_reply_to.startswith(ID) and self.content # Hide votes from Question + ) + @property def is_in_reply_to_from_inbox(self) -> bool | None: if not self.in_reply_to: diff --git a/app/boxes.py b/app/boxes.py index 296844b..343811e 100644 --- a/app/boxes.py +++ b/app/boxes.py @@ -1909,11 +1909,7 @@ async def _process_note_object( is_from_following = ro.actor.ap_id in {f.ap_actor_id for f in following} is_reply = bool(ro.in_reply_to) - is_local_reply = bool( - ro.in_reply_to - and ro.in_reply_to.startswith(BASE_URL) - and ro.content # Hide votes from Question - ) + is_local_reply = ro.is_local_reply is_mention = False hashtags = [] tags = ro.ap_object.get("tag", []) diff --git a/app/templates/utils.html b/app/templates/utils.html index 7bc01a9..4da08da 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -751,7 +751,7 @@ {{ admin_expand_button(object) }} {% endif %} - {% if object.is_from_inbox and not object.announced_via_outbox_object_ap_id %} + {% if object.is_from_inbox and not object.announced_via_outbox_object_ap_id and object.is_local_reply %}
  • {{ admin_force_delete_button(object.ap_id) }}