mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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:
@@ -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_"`
|
||||
|
Reference in New Issue
Block a user