email_addresses.rb 634 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class EmailAddresses < BaseQuery
  4. description 'EmailAddresses available in the system'
  5. argument :only_active, Boolean, required: false, description: 'Fetch only active addresses'
  6. type [Gql::Types::EmailAddressType, { null: false }], null: false
  7. def self.authorize(_obj, ctx)
  8. ctx.current_user.permissions?(['ticket.agent', 'admin.channel_email', 'admin.wizard'])
  9. end
  10. def resolve(only_active: false)
  11. return EmailAddress.where(active: true) if only_active
  12. EmailAddress.all
  13. end
  14. end
  15. end