From 9efb11d8485f8273f7d64d46f2675a78fc41d6e8 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:47:57 +0200 Subject: [feature/frontend] Add player for audio files; use thumbnail for `poster` (#3099) * [feature/frontend] Audio player for audio media types * use video preview images for previews instead of video itself * don't preload * update tests for new zork status * collapse media gallery into single row when small --- internal/typeutils/internaltofrontend.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'internal/typeutils/internaltofrontend.go') diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 9d99205f6..d24ae3ea5 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -624,7 +624,7 @@ func (c *Converter) AttachmentToAPIAttachment(ctx context.Context, a *gtsmodel.M Y: a.FileMeta.Focus.Y, } - case gtsmodel.FileTypeVideo: + case gtsmodel.FileTypeVideo, gtsmodel.FileTypeAudio: if i := a.FileMeta.Original.Duration; i != nil { apiAttachment.Meta.Original.Duration = *i } @@ -1062,14 +1062,36 @@ func (c *Converter) StatusToWebStatus( webStatus.PollOptions = PollOptions } + // Mark local. + webStatus.Local = *s.Local + // Set additional templating // variables on media attachments. - for _, a := range webStatus.MediaAttachments { - a.Sensitive = webStatus.Sensitive + + // Get gtsmodel attachments + // into a convenient map. + ogAttachments := make( + map[string]*gtsmodel.MediaAttachment, + len(s.Attachments), + ) + for _, a := range s.Attachments { + ogAttachments[a.ID] = a } - // Mark this as a local status. - webStatus.Local = *s.Local + // Convert each API attachment + // into a web attachment. + webStatus.MediaAttachments = make( + []*apimodel.WebAttachment, + len(apiStatus.MediaAttachments), + ) + for i, apiAttachment := range apiStatus.MediaAttachments { + ogAttachment := ogAttachments[apiAttachment.ID] + webStatus.MediaAttachments[i] = &apimodel.WebAttachment{ + Attachment: apiAttachment, + Sensitive: apiStatus.Sensitive, + MIMEType: ogAttachment.File.ContentType, + } + } return webStatus, nil } -- cgit v1.2.3