list.rb 517 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class User::Current::Device::List < BaseQuery
  4. description 'Fetch available device list of the currently logged-in user'
  5. type [Gql::Types::UserDeviceType], null: true
  6. def self.authorize(_obj, ctx)
  7. ctx.current_user.permissions?('user_preferences.device')
  8. end
  9. def resolve(...)
  10. UserDevice.where(user_id: context.current_user.id).reorder(updated_at: :desc, name: :asc)
  11. end
  12. end
  13. end