Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions app/models/card/readable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ def unread_by(user)
end

def remove_inaccessible_notifications
User.find_each do |user|
all_notifications_for(user).destroy_all unless accessible_to?(user)
accessible_user_ids = board.accesses.pluck(:user_id)
notification_sources.each do |sources|
inaccessible_notifications_from(sources, accessible_user_ids).in_batches.destroy_all
end
end

Expand Down Expand Up @@ -44,6 +45,14 @@ def comment_creation_events
Event.where(eventable: comments)
end

def inaccessible_notifications_from(sources, accessible_user_ids)
Notification.where(source: sources).where.not(user_id: accessible_user_ids)
end

def notification_sources
[ events, comment_creation_events, mentions, comment_mentions ]
end

def mention_notification_sources
mentions.or(comment_mentions)
end
Expand Down