add.rb 795 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Mutations
  3. class Account::Avatar::Add < BaseMutation
  4. description 'Add a new avatar for the currently logged in user.'
  5. argument :images, Gql::Types::Input::AvatarInputType, description: 'Images to be uploaded.'
  6. field :avatar, Gql::Types::AvatarType, description: 'The newly created avatar.'
  7. def resolve(images:)
  8. file_full = images[:full]
  9. file_resize = images[:resize]
  10. if file_full[:error].present? || file_resize[:error].present?
  11. return error_response({ message: file_full[:message] || file_resize[:message] })
  12. end
  13. {
  14. avatar: execute_service(Avatar::AddService, full_image: file_full, resize_image: file_resize)
  15. }
  16. end
  17. end
  18. end