upload_cache_policy.rb 434 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class UploadCachePolicy < ApplicationPolicy
  3. %i[
  4. add?
  5. any?
  6. attachments?
  7. destroy?
  8. remove_item?
  9. show?
  10. ].each do |action|
  11. define_method(action) { permission? }
  12. end
  13. private
  14. def permission?
  15. attachments = record.attachments
  16. return true if attachments.blank?
  17. attachments.first.created_by_id == user.id
  18. end
  19. end