File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,9 @@ def unread_by(user)
1414 end
1515
1616 def remove_inaccessible_notifications
17- User . find_each do |user |
18- all_notifications_for ( user ) . destroy_all unless accessible_to? ( user )
17+ accessible_user_ids = board . accesses . pluck ( :user_id )
18+ notification_sources . each do |sources |
19+ inaccessible_notifications_from ( sources , accessible_user_ids ) . in_batches . destroy_all
1920 end
2021 end
2122
@@ -44,6 +45,14 @@ def comment_creation_events
4445 Event . where ( eventable : comments )
4546 end
4647
48+ def inaccessible_notifications_from ( sources , accessible_user_ids )
49+ Notification . where ( source : sources ) . where . not ( user_id : accessible_user_ids )
50+ end
51+
52+ def notification_sources
53+ [ events , comment_creation_events , mentions , comment_mentions ]
54+ end
55+
4756 def mention_notification_sources
4857 mentions . or ( comment_mentions )
4958 end
You can’t perform that action at this time.
0 commit comments