demarches-normaliennes/app/graphql/mutations/base_mutation.rb

18 lines
596 B
Ruby
Raw Normal View History

2018-11-20 22:59:13 +01:00
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
2018-11-20 22:59:13 +01:00
end
end