form_id.rb 702 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class FormUpdater::ApplyValue::FormId < FormUpdater::ApplyValue::Base
  3. def can_handle_field?(field:, field_attribute:)
  4. field == 'form_id'
  5. end
  6. def map_value(field:, config:)
  7. attachments = []
  8. UploadCache.new(config['value'])
  9. .attachments
  10. .reject(&:inline?)
  11. .map do |attachment|
  12. attachments << {
  13. id: Gql::ZammadSchema.id_from_object(attachment),
  14. name: attachment.filename,
  15. size: attachment.size,
  16. type: attachment.preferences['Content-Type'],
  17. }
  18. end
  19. result['attachments'] ||= {}
  20. result['attachments'][:value] = attachments
  21. end
  22. end