devices_updates.rb 601 B

1234567891011121314151617181920
  1. # Copyright (C) 2012-2025 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class User::Current::DevicesUpdates < BaseSubscription
  4. description 'Updates to account devices records'
  5. subscription_scope :current_user_id
  6. field :devices, [Gql::Types::UserDeviceType], null: true, description: 'List of devices for the user'
  7. def authorized?
  8. context.current_user.permissions?('user_preferences.device')
  9. end
  10. def update
  11. { devices: UserDevice.where(user_id: context.current_user.id).reorder(updated_at: :desc, name: :asc) }
  12. end
  13. end
  14. end