This commit is contained in:
Mirai Kumiko 2025-07-05 15:20:40 +02:00
parent 188bc08494
commit 4af88f3e1d
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
44 changed files with 1041 additions and 34 deletions

View file

@ -0,0 +1,30 @@
defmodule NullaWeb.Api.MediaAttachmentJSON do
alias Nulla.MediaAttachments.MediaAttachment
@doc """
Renders a list of media_attachments.
"""
def index(%{media_attachments: media_attachments}) do
%{data: for(media_attachment <- media_attachments, do: data(media_attachment))}
end
@doc """
Renders a single media_attachment.
"""
def show(%{media_attachment: media_attachment}) do
%{data: data(media_attachment)}
end
defp data(%MediaAttachment{} = media_attachment) do
%{
id: media_attachment.id,
type: media_attachment.type,
mediaType: media_attachment.mediaType,
url: media_attachment.url,
name: media_attachment.name,
width: media_attachment.width,
height: media_attachment.height,
note_id: media_attachment.note_id
}
end
end