// MediaAttachment represents a user-uploaded media attachment: an image/video/audio/gif that is
// somewhere in storage and that can be retrieved and served by the router.
typeMediaAttachmentstruct{
IDstring`validate:"required,ulid" bun:"type:CHAR(26),pk,nullzero,notnull,unique"`// id of this item in the database
CreatedAttime.Time`validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`// when was item created
UpdatedAttime.Time`validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`// when was item last updated
StatusIDstring`validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`// ID of the status to which this is attached
URLstring`validate:"required_without=RemoteURL,omitempty,url" bun:",nullzero"`// Where can the attachment be retrieved on *this* server
RemoteURLstring`validate:"required_without=URL,omitempty,url" bun:",nullzero"`// Where can the attachment be retrieved on a remote server (empty for local media)
TypeFileType`validate:"oneof=Image Gif Audio Video Unknown" bun:",nullzero,notnull"`// Type of file (image/gif/audio/video)
AccountIDstring`validate:"required,ulid" bun:"type:CHAR(26),nullzero,notnull"`// To which account does this attachment belong
Account*Account`validate:"-" bun:"rel:has-one"`// Account corresponding to accountID
Descriptionstring`validate:"-" bun:""`// Description of the attachment (for screenreaders)
ScheduledStatusIDstring`validate:"omitempty,ulid" bun:"type:CHAR(26),nullzero"`// To which scheduled status does this attachment belong
Blurhashstring`validate:"required_if=Type Image,required_if=Type Gif,required_if=Type Video" bun:",nullzero"`// What is the generated blurhash of this attachment
ProcessingProcessingStatus`validate:"oneof=0 1 2 666" bun:",notnull,default:2"`// What is the processing status of this attachment
FileFile`validate:"required" bun:",embed:file_,notnull,nullzero"`// metadata for the whole file
ThumbnailThumbnail`validate:"required" bun:",embed:thumbnail_,notnull,nullzero"`// small image thumbnail derived from a larger image, video, or audio file.
Avatarbool`validate:"-" bun:",notnull,default:false"`// Is this attachment being used as an avatar?
Headerbool`validate:"-" bun:",notnull,default:false"`// Is this attachment being used as a header?
Cachedbool`validate:"-" bun:",notnull"`// Is this attachment currently cached by our instance?
}
// File refers to the metadata for the whole file
typeFilestruct{
Pathstring`validate:"required,file" bun:",nullzero,notnull"`// Path of the file in storage.
ContentTypestring`validate:"required" bun:",nullzero,notnull"`// MIME content type of the file.
FileSizeint`validate:"required" bun:",notnull"`// File size in bytes
UpdatedAttime.Time`validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`// When was the file last updated.
}
// Thumbnail refers to a small image thumbnail derived from a larger image, video, or audio file.
typeThumbnailstruct{
Pathstring`validate:"required,file" bun:",nullzero,notnull"`// Path of the file in storage.
ContentTypestring`validate:"required" bun:",nullzero,notnull"`// MIME content type of the file.
FileSizeint`validate:"required" bun:",notnull"`// File size in bytes
UpdatedAttime.Time`validate:"-" bun:"type:timestamptz,nullzero,notnull,default:current_timestamp"`// When was the file last updated.
URLstring`validate:"required_without=RemoteURL,omitempty,url" bun:",nullzero"`// What is the URL of the thumbnail on the local server
RemoteURLstring`validate:"required_without=URL,omitempty,url" bun:",nullzero"`// What is the remote URL of the thumbnail (empty for local media)
}
// ProcessingStatus refers to how far along in the processing stage the attachment is.
typeProcessingStatusint
// MediaAttachment processing states.
const(
ProcessingStatusReceivedProcessingStatus=0// ProcessingStatusReceived indicates the attachment has been received and is awaiting processing. No thumbnail available yet.
ProcessingStatusProcessingProcessingStatus=1// ProcessingStatusProcessing indicates the attachment is currently being processed. Thumbnail is available but full media is not.
ProcessingStatusProcessedProcessingStatus=2// ProcessingStatusProcessed indicates the attachment has been fully processed and is ready to be served.
ProcessingStatusErrorProcessingStatus=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.
typeFileTypestring
// MediaAttachment file types.
const(
FileTypeImageFileType="Image"// FileTypeImage is for jpegs and pngs
FileTypeGifFileType="Gif"// FileTypeGif is for native gifs and soundless videos that have been converted to gifs
FileTypeAudioFileType="Audio"// FileTypeAudio is for audio-only files (no video)
FileTypeVideoFileType="Video"// FileTypeVideo is for files with audio + visual
FileTypeUnknownFileType="Unknown"// FileTypeUnknown is for unknown file types (surprise surprise!)
)
// FileMeta describes metadata about the actual contents of the file.