From d45d1b39464ee3baec4f962c46ec01e8074c8c6f Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 25 Feb 2024 10:45:07 -0500 Subject: [PATCH] do not send notification for self boost --- common/templates/_sidebar.html | 2 +- journal/templates/wrapped.html | 2 +- neodb-takahe | 2 +- social/templates/feed_data.html | 2 +- takahe/ap_handlers.py | 18 ++++++++++++++++-- users/models/apidentity.py | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/common/templates/_sidebar.html b/common/templates/_sidebar.html index 0e2f6132..e6bb9d2c 100644 --- a/common/templates/_sidebar.html +++ b/common/templates/_sidebar.html @@ -47,7 +47,7 @@
{{ identity.display_name }}
- {{ identity.full_handle }} + @{{ identity.full_handle }}
diff --git a/journal/templates/wrapped.html b/journal/templates/wrapped.html index 9449139e..4d5885fb 100644 --- a/journal/templates/wrapped.html +++ b/journal/templates/wrapped.html @@ -62,7 +62,7 @@ var cats = JSON.parse(document.getElementById('cat-data').textContent); var data = JSON.parse(document.getElementById('data').textContent); var opts = { - title: "{{ identity.user.mastodon_acct | default:identity.full_handle }} - {{ year }}", + title: "@{{ identity.user.mastodon_acct | default:identity.full_handle }} - {{ year }}", element: '#viz0', font: 1, data: data, diff --git a/neodb-takahe b/neodb-takahe index f0b9db2d..28ea5961 160000 --- a/neodb-takahe +++ b/neodb-takahe @@ -1 +1 @@ -Subproject commit f0b9db2d033d6315792a7d75caa5b8eaceec0eae +Subproject commit 28ea59618ceb1132e86a9f7e070c15ebf3425c81 diff --git a/social/templates/feed_data.html b/social/templates/feed_data.html index 0c313689..6ff481c7 100644 --- a/social/templates/feed_data.html +++ b/social/templates/feed_data.html @@ -24,7 +24,7 @@ {{ activity.owner.display_name }} - {{ activity.owner.full_handle }} + @{{ activity.owner.full_handle }} {% with "activity/"|add:activity.template|add:".html" as template %} diff --git a/takahe/ap_handlers.py b/takahe/ap_handlers.py index d96c2b1f..0b401a47 100644 --- a/takahe/ap_handlers.py +++ b/takahe/ap_handlers.py @@ -6,7 +6,7 @@ from catalog.common import * from journal.models import Comment, Piece, PieceInteraction, Rating, Review, ShelfMember from users.models.apidentity import APIdentity -from .models import Follow, Identity, Post +from .models import Follow, Identity, Post, TimelineEvent from .utils import Takahe _supported_ap_catalog_item_types = [ @@ -128,9 +128,23 @@ def post_interacted(interaction_pk, interaction, post_pk, identity_pk): p = Piece.objects.filter(posts__id=post_pk).first() if not p: return - if not APIdentity.objects.filter(pk=identity_pk).exists(): + apid = APIdentity.objects.filter(pk=identity_pk).first() + if not apid: logger.warning(f"Identity {identity_pk} not found for interaction") return + if ( + interaction == "boost" + and p.local + and p.owner.user.mastodon_acct == apid.full_handle + ): + # ignore boost by oneself + TimelineEvent.objects.filter( + identity_id=p.owner_id, + type="boosted", + subject_post_id=post_pk, + subject_identity_id=identity_pk, + ).delete() + return PieceInteraction.objects.get_or_create( target=p, identity_id=identity_pk, diff --git a/users/models/apidentity.py b/users/models/apidentity.py index ad6a7556..33a50353 100644 --- a/users/models/apidentity.py +++ b/users/models/apidentity.py @@ -98,7 +98,7 @@ class APIdentity(models.Model): @property def full_handle(self): - return f"@{self.username}@{self.domain_name}" + return f"{self.username}@{self.domain_name}" @property def handler(self):