update.rb 821 B

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