Files
Rosa Gutierrez ee636f1994 Delete orphaned watches and pins when a card is moved to a private board
For watchers and users with pins that don't have access to the private
board where the card was moved to.
2026-01-14 19:38:15 +01:00

27 lines
640 B
Ruby

module Card::Accessible
extend ActiveSupport::Concern
included do
delegate :accessible_to?, to: :board
end
def publicly_accessible?
published? && board.publicly_accessible?
end
def clean_inaccessible_data
accessible_user_ids = board.accesses.pluck(:user_id)
pins.where.not(user_id: accessible_user_ids).in_batches.destroy_all
watches.where.not(user_id: accessible_user_ids).in_batches.destroy_all
end
private
def grant_access_to_assignees
board.accesses.grant_to(assignees)
end
def clean_inaccessible_data_later
Card::CleanInaccessibleDataJob.perform_later(self)
end
end