mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-14 12:16:31 +00:00
Avoid duplicate notifitions
And render html
This commit is contained in:
parent
d79a756813
commit
f1926ce76d
2 changed files with 5 additions and 2 deletions
|
@ -218,7 +218,9 @@ def handle_create(activity):
|
||||||
|
|
||||||
status = activity.to_model(model)
|
status = activity.to_model(model)
|
||||||
# create a notification if this is a reply
|
# create a notification if this is a reply
|
||||||
|
notified = []
|
||||||
if status.reply_parent and status.reply_parent.user.local:
|
if status.reply_parent and status.reply_parent.user.local:
|
||||||
|
notified.append(status.reply_parent.user)
|
||||||
status_builder.create_notification(
|
status_builder.create_notification(
|
||||||
status.reply_parent.user,
|
status.reply_parent.user,
|
||||||
'REPLY',
|
'REPLY',
|
||||||
|
@ -226,7 +228,8 @@ def handle_create(activity):
|
||||||
related_status=status,
|
related_status=status,
|
||||||
)
|
)
|
||||||
if status.mention_users.exists():
|
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:
|
if not mentioned_user.local:
|
||||||
continue
|
continue
|
||||||
status_builder.create_notification(
|
status_builder.create_notification(
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
<div class="notification py-2 {% if notification.id in unread %}is-primary is-light{% else %}has-background-white{% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %} has-text-black{% else %}-bis has-text-grey-dark{% endif %}{% endif %}">
|
<div class="notification py-2 {% if notification.id in unread %}is-primary is-light{% else %}has-background-white{% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %} has-text-black{% else %}-bis has-text-grey-dark{% endif %}{% endif %}">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<a href="{{ notification.related_status.remote_id }}">{{ notification.related_status.content | truncatewords_html:10 }}</a>
|
<a href="{{ notification.related_status.remote_id }}">{{ notification.related_status.content | safe | truncatewords_html:10 }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-narrow {% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %}has-text-black{% else %}has-text-grey-dark{% endif %}">
|
<div class="column is-narrow {% if notification.notification_type == 'REPLY' or notification.notification_type == 'MENTION' %}has-text-black{% else %}has-text-grey-dark{% endif %}">
|
||||||
{{ notification.related_status.published_date | post_date }}
|
{{ notification.related_status.published_date | post_date }}
|
||||||
|
|
Loading…
Reference in a new issue