diff options
author | 2024-07-17 15:26:33 +0000 | |
---|---|---|
committer | 2024-07-17 15:26:33 +0000 | |
commit | 72ba5666a6ffd06ccdfd2db8dacc47de7f777a4c (patch) | |
tree | ac8c71af4f9a57c0233ffd30f8867d02616c46cc /internal/gtsmodel/mediaattachment.go | |
parent | [feature] Allow users to set default interaction policies per status visibili... (diff) | |
download | gotosocial-72ba5666a6ffd06ccdfd2db8dacc47de7f777a4c.tar.xz |
[chore] media pipeline improvements (#3110)
* don't set emoji / media image paths on failed download, migrate FileType from string to integer
* fix incorrect uses of util.PtrOr, fix returned frontend media
* fix migration not setting arguments correctly in where clause
* fix not providing default with not null column
* whoops
* ensure a default gets set for media attachment file type
* remove the exclusive flag from writing files in disk storage
* rename PtrOr -> PtrOrZero, and rename PtrValueOr -> PtrOrValue to match
* slight wording changes
* use singular / plural word forms (no parentheses), is better for screen readers
* update testmodels with unknown media type to have unset file details, update attachment focus handling converting to frontend, update tests
* store first instance in ffmpeg wasm pool, fill remaining with closed instances
Diffstat (limited to 'internal/gtsmodel/mediaattachment.go')
-rw-r--r-- | internal/gtsmodel/mediaattachment.go | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/internal/gtsmodel/mediaattachment.go b/internal/gtsmodel/mediaattachment.go index 471a5abd1..eb792ae3b 100644 --- a/internal/gtsmodel/mediaattachment.go +++ b/internal/gtsmodel/mediaattachment.go @@ -30,7 +30,7 @@ type MediaAttachment struct { StatusID string `bun:"type:CHAR(26),nullzero"` // ID of the status to which this is attached URL string `bun:",nullzero"` // Where can the attachment be retrieved on *this* server RemoteURL string `bun:",nullzero"` // Where can the attachment be retrieved on a remote server (empty for local media) - Type FileType `bun:",notnull"` // Type of file (image/gifv/audio/video/unknown) + Type FileType `bun:",notnull,default:0"` // Type of file (image/gifv/audio/video/unknown) FileMeta FileMeta `bun:",embed:,notnull"` // Metadata about the file AccountID string `bun:"type:CHAR(26),nullzero,notnull"` // To which account does this attachment belong Description string `bun:""` // Description of the attachment (for screenreaders) @@ -81,18 +81,34 @@ const ( ProcessingStatusError ProcessingStatus = 666 // ProcessingStatusError indicates something went wrong processing the attachment and it won't be tried again--these can be deleted. ) -// FileType refers to the file type of the media attaachment. -type FileType string +// FileType refers to the file +// type of the media attaachment. +type FileType int -// MediaAttachment file types. const ( - FileTypeImage FileType = "Image" // FileTypeImage is for jpegs, pngs, and standard gifs - FileTypeGifv FileType = "Gifv" // FileTypeGif is for soundless looping videos that behave like gifs - FileTypeAudio FileType = "Audio" // FileTypeAudio is for audio-only files (no video) - FileTypeVideo FileType = "Video" // FileTypeVideo is for files with audio + visual - FileTypeUnknown FileType = "Unknown" // FileTypeUnknown is for unknown file types (surprise surprise!) + // MediaAttachment file types. + FileTypeUnknown FileType = 0 // FileTypeUnknown is for unknown file types (surprise surprise!) + FileTypeImage FileType = 1 // FileTypeImage is for jpegs, pngs, and standard gifs + FileTypeAudio FileType = 2 // FileTypeAudio is for audio-only files (no video) + FileTypeVideo FileType = 3 // FileTypeVideo is for files with audio + visual ) +// String returns a stringified, frontend API compatible form of FileType. +func (t FileType) String() string { + switch t { + case FileTypeUnknown: + return "unknown" + case FileTypeImage: + return "image" + case FileTypeAudio: + return "audio" + case FileTypeVideo: + return "video" + default: + panic("invalid filetype") + } +} + // FileMeta describes metadata about the actual contents of the file. type FileMeta struct { Original Original `bun:"embed:original_"` |