Merge pull request #10505 from colinux/fix-api-v1-commentaire-pj

API v1: fix régression commentaire -> attachment url qui avait sauté
This commit is contained in:
Eric Leroy-Terquem 2024-06-10 14:04:44 +00:00 committed by GitHub
commit c893f8de99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,9 +2,18 @@ class CommentaireSerializer < ActiveModel::Serializer
attributes :email,
:body,
:created_at,
:piece_jointe_attachments
:piece_jointe_attachments,
:attachment
def created_at
object.created_at&.in_time_zone('UTC')
end
def attachment
piece_jointe = object.piece_jointe_attachments.first
if piece_jointe&.virus_scanner&.safe?
Rails.application.routes.url_helpers.url_for(piece_jointe)
end
end
end