overview_ordering_updates.rb 904 B

1234567891011121314151617181920212223242526272829
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class User::Current::OverviewOrderingUpdates < BaseSubscription
  4. argument :user_id, GraphQL::Types::ID, 'ID of the user to receive overview sorting updates for', loads: Gql::Types::UserType
  5. description 'Updates to account overview sorting records'
  6. field :overviews, [Gql::Types::OverviewType], null: true, description: 'List of overview sortings for the user'
  7. def authorized?(user:)
  8. context.current_user.permissions?('user_preferences.overview_sorting') && user.id == context.current_user.id
  9. end
  10. def update(user:)
  11. { overviews: Service::User::Overview::List.new(user).execute }
  12. end
  13. def self.trigger_by(user)
  14. trigger(
  15. nil,
  16. arguments: {
  17. user_id: Gql::ZammadSchema.id_from_object(user)
  18. }
  19. )
  20. end
  21. end
  22. end