link_updates.rb 919 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Subscriptions
  3. class LinkUpdates < BaseSubscription
  4. include Gql::Concerns::HandlesPossibleObjects
  5. description 'Updates to link records'
  6. argument :object_id, GraphQL::Types::ID, required: true, description: 'Linked object identifier'
  7. argument :target_type, String, required: true, description: 'Target type'
  8. field :links, [Gql::Types::LinkType], null: true, description: 'Link records'
  9. possible_objects ::Ticket, ::KnowledgeBase::Answer::Translation
  10. def authorized?(object_id:, target_type:)
  11. fetch_object(object_id)
  12. end
  13. def update(object_id:, target_type:)
  14. object = Gql::ZammadSchema.object_from_id(object_id)
  15. links = Service::Link::List
  16. .new(current_user: context.current_user)
  17. .execute(object:, target_type:)
  18. { links: links }
  19. end
  20. end
  21. end