demarches-normaliennes/app/graphql/mutations/base_mutation.rb
Paul Chavard 00ef56db10 [GraphQL] fix attachment upload
- `identify` will return `true` sometime
2020-11-25 10:46:20 +01:00

17 lines
596 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module Mutations
class BaseMutation < GraphQL::Schema::RelayClassicMutation
def validate_blob(blob_id)
if blob_id.present?
begin
blob = ActiveStorage::Blob.find_signed(blob_id)
blob.identify
nil
rescue ActiveStorage::FileNotFoundError
return { errors: ['Le fichier na pas été correctement téléversé sur le serveur de stockage'] }
rescue ActiveSupport::MessageVerifier::InvalidSignature
return { errors: ['Lidentifiant du fichier téléversé est invalide'] }
end
end
end
end
end