From f1926ce76d79d5a9917f7e75ca7c4352e9af4176 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 16 Dec 2020 16:20:40 -0800 Subject: [PATCH 1/2] Avoid duplicate notifitions And render html --- bookwyrm/incoming.py | 5 ++++- bookwyrm/templates/notifications.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index 556c34a27..78e7b9707 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -218,7 +218,9 @@ def handle_create(activity): status = activity.to_model(model) # create a notification if this is a reply + notified = [] if status.reply_parent and status.reply_parent.user.local: + notified.append(status.reply_parent.user) status_builder.create_notification( status.reply_parent.user, 'REPLY', @@ -226,7 +228,8 @@ def handle_create(activity): related_status=status, ) if status.mention_users.exists(): - for mentioned_user in status.mention_users.all(): + for mentioned_user in status.mention_users.all() and \ + mentioned_user not in notified: if not mentioned_user.local: continue status_builder.create_notification( diff --git a/bookwyrm/templates/notifications.html b/bookwyrm/templates/notifications.html index f31df76d8..ddcbc0fda 100644 --- a/bookwyrm/templates/notifications.html +++ b/bookwyrm/templates/notifications.html @@ -54,7 +54,7 @@
{{ notification.related_status.published_date | post_date }} From f7cb52598144aa896e8d9518dbb67b03b1b8b70c Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 16 Dec 2020 18:40:43 -0800 Subject: [PATCH 2/2] Fixes logic error --- bookwyrm/incoming.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index 78e7b9707..c1c15ca93 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -228,9 +228,8 @@ def handle_create(activity): related_status=status, ) if status.mention_users.exists(): - for mentioned_user in status.mention_users.all() and \ - mentioned_user not in notified: - if not mentioned_user.local: + for mentioned_user in status.mention_users.all(): + if not mentioned_user.local or mentioned_user in notified: continue status_builder.create_notification( mentioned_user,