create.rb 792 B

12345678910111213141516171819202122232425262728
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::Ticket::SharedDraft::Zoom::Create < Service::Base
  3. attr_reader :user, :form_id, :ticket, :new_article, :ticket_attributes
  4. def initialize(user, form_id, ticket:, new_article:, ticket_attributes:)
  5. super()
  6. @user = user
  7. @form_id = form_id
  8. @ticket = ticket
  9. @new_article = new_article
  10. @ticket_attributes = ticket_attributes
  11. end
  12. def execute
  13. shared_draft = ::Ticket::SharedDraftZoom.new(ticket:, new_article:, ticket_attributes:)
  14. Pundit.authorize(user, shared_draft, :update?)
  15. UserInfo.with_user_id(user.id) do
  16. shared_draft.save!
  17. shared_draft.attach_upload_cache(form_id)
  18. end
  19. shared_draft
  20. end
  21. end