[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
This commit is contained in:
kim
2024-07-17 15:26:33 +00:00
committed by GitHub
parent 0aadc2db2a
commit 72ba5666a6
29 changed files with 669 additions and 399 deletions

View File

@@ -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_"`