perform_changes.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Ticket::PerformChanges
  3. extend ActiveSupport::Concern
  4. include CanPerformChanges
  5. included do
  6. available_perform_change_actions :delete,
  7. :data_privacy_deletion_task,
  8. :attribute_updates,
  9. :notification_email,
  10. :notification_sms,
  11. :notification_webhook,
  12. :article_note
  13. end
  14. def pre_execute(perform_changes_data)
  15. article = begin
  16. Ticket::Article.find_by(id: perform_changes_data[:context_data].try(:dig, :article_id))
  17. rescue ArgumentError
  18. nil
  19. end
  20. return if article.nil?
  21. perform_changes_data[:context_data][:article] = article
  22. end
  23. def additional_object_action(object_name, object_key, action_value, _prepared_actions)
  24. return if !object_name.eql?('article')
  25. return if %w[note].exclude?(object_key)
  26. { name: :"article_#{object_key.to_sym}", value: action_value }
  27. end
  28. end