summaryrefslogtreecommitdiff
path: root/internal/typeutils/internaltofrontend.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2024-07-15 11:47:57 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-15 10:47:57 +0100
commit9efb11d8485f8273f7d64d46f2675a78fc41d6e8 (patch)
treec58847c1afc0d29110d06c8b6a7a24652f53dc6b /internal/typeutils/internaltofrontend.go
parent[chore]: Bump github.com/tdewolff/minify/v2 from 2.20.34 to 2.20.37 (#3106) (diff)
downloadgotosocial-9efb11d8485f8273f7d64d46f2675a78fc41d6e8.tar.xz
[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
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r--internal/typeutils/internaltofrontend.go32
1 files changed, 27 insertions, 5 deletions
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
}