user_updates.rb 651 B

123456789101112131415161718192021
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class UserUpdates < BaseSubscription
  4. argument :user_id, GraphQL::Types::ID, 'ID of the user to receive updates for'
  5. description 'Updates to user records'
  6. field :user, Gql::Types::UserType, description: 'Updated user'
  7. # Instance method: allow subscriptions only for users where the current user has read permission for.
  8. def authorized?(user_id:)
  9. ::Gql::ZammadSchema.authorized_object_from_id user_id, type: ::User, user: context.current_user
  10. end
  11. def update(user_id:)
  12. { user: object }
  13. end
  14. end
  15. end