diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-02-12 11:12:41 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2022-02-12 11:12:41 +0100 |
commit | d9379f53312f1bee490afb0fd7dc368df1a4a96d (patch) | |
tree | 1decb10519ec165483b735095e92ab2e94c2d080 /app/workers | |
parent | 28ec7def5869ff1a85f49a070b9575c166a432ee (diff) | |
parent | 79b167f01a91f79d92afb442de282ded8696066a (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
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 |