taskbar_item_updates.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class User::Current::TaskbarItemUpdates < BaseSubscription
  4. description 'Changes to the list of taskbar items of the currently logged-in user'
  5. argument :user_id, GraphQL::Types::ID, loads: Gql::Types::UserType, description: 'Filter by user'
  6. argument :app, Gql::Types::Enum::TaskbarAppType, description: 'Filter by app'
  7. field :add_item, Gql::Types::User::TaskbarItemType, description: 'A new taskbar item needs to be added to the list'
  8. field :update_item, Gql::Types::User::TaskbarItemType, description: 'An existing taskbar item was changed'
  9. field :remove_item, GraphQL::Types::ID, description: 'An item must be removed from the list'
  10. class << self
  11. def trigger_after_create(item)
  12. pull_trigger(item, { add_item: item })
  13. end
  14. def trigger_after_update(item)
  15. pull_trigger(item, { update_item: item })
  16. end
  17. def trigger_after_destroy(item)
  18. pull_trigger(item, { remove_item: Gql::ZammadSchema.id_from_object(item) })
  19. end
  20. def pull_trigger(item, payload)
  21. user_id = Gql::ZammadSchema.id_from_internal_id(::User, item.user_id)
  22. trigger(payload, arguments: { user_id:, app: item.app })
  23. end
  24. end
  25. def authorized?(user:, app:)
  26. user == context.current_user
  27. end
  28. def update(user:, app:)
  29. object
  30. end
  31. end
  32. end