suggestions.rb 900 B

12345678910111213141516171819202122232425
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class Mention::Suggestions < BaseQuery
  4. description 'Suggestions for mentionable users in a new ticket article'
  5. argument :query, String, description: 'User to search for'
  6. argument :group_id, GraphQL::Types::ID, loads: Gql::Types::GroupType, description: 'A group to which the Users have to be allocated to'
  7. type [Gql::Types::UserType], null: true
  8. def self.authorize(_obj, ctx)
  9. ctx.current_user.permissions?('ticket.agent')
  10. end
  11. def resolve(query:, group:)
  12. ::User.search({
  13. query: query,
  14. group_ids: { group.id => 'read' },
  15. role_ids: Role.with_permissions('ticket.agent').map(&:id),
  16. current_user: context.current_user,
  17. })
  18. end
  19. end
  20. end