diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-02-11 22:20:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-11 22:20:19 +0100 |
commit | 8f03b7a2fb4b420eb46942157160816185e81751 (patch) | |
tree | 125819d272db5626bbd41406c633ef39ccd334da /app/workers | |
parent | d0fcf07436d158bcac2617d076a83d0aa49c39e6 (diff) |
Add notifications when a reblogged status has been updated (#17404)
* Add notifications when a reblogged status has been updated * Change wording to say "edit" instead of "update" and add missing controls * Replace previous update notifications with the most up-to-date one
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/local_notification_worker.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/app/workers/local_notification_worker.rb b/app/workers/local_notification_worker.rb index a22e2834d..749a54b73 100644 --- a/app/workers/local_notification_worker.rb +++ b/app/workers/local_notification_worker.rb @@ -12,7 +12,14 @@ class LocalNotificationWorker activity = activity_class_name.constantize.find(activity_id) end - return if Notification.where(account: receiver, activity: activity).any? + # For most notification types, only one notification should exist, and the older one is + # preferred. For updates, such as when a status is edited, the new notification + # should replace the previous ones. + if type == 'update' + Notification.where(account: receiver, activity: activity, type: 'update').in_batches.delete_all + elsif Notification.where(account: receiver, activity: activity, type: type).any? + return + end NotifyService.new.call(receiver, type || activity_class_name.underscore, activity) rescue ActiveRecord::RecordNotFound |