50 lines
2 KiB
Go
50 lines
2 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// MediaMetadata contains metadata about some media file.
|
|
// These files are never stored directly by Linstrom.
|
|
// Instead, they are either stored on the remote server they originated from
|
|
// or an s3 bucket if uploaded to Linstrom.
|
|
type MediaMetadata struct {
|
|
ID string `gorm:"primarykey;type:uuid;default:gen_random_uuid()"` // The unique ID of this media file
|
|
CreatedAt time.Time // When this entry was created
|
|
UpdatedAt time.Time // When this entry was last updated
|
|
// When this entry was deleted (for soft deletions)
|
|
// Soft delete means that this entry still exists in the db, but gorm won't include it anymore unless specifically told to
|
|
// If not null, this entry is marked as deleted
|
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
|
OwnedById string // Account id this media belongs to
|
|
Remote bool // whether the attachment is a remote one
|
|
// Where the media is stored. Url
|
|
Location string
|
|
Type string // What media type this is following mime types, eg image/png
|
|
// Name of the file
|
|
// Could be <emote-name>.png, <server-name>.webp for example. Or the name the file was uploaded with
|
|
Name string
|
|
// Alternative description of the media file's content
|
|
AltText string
|
|
// Whether the media is to be blurred by default
|
|
Blurred bool
|
|
}
|
|
|
|
// TODO: Implement special handling for the linstrom URI type
|
|
// Linstrom URIs indicate resource either generated on the fly, like identicons,
|
|
// or embedded data, such as the default duck
|
|
// For external users, transform them into normal http URIs with a "special" path
|
|
const DefaultDuckLocationName = "linstrom://default-media"
|
|
|
|
var DefaultDuckMedia = MediaMetadata{
|
|
ID: "3b562a45-36b7-4c42-a944-3672f319ff7b",
|
|
OwnedById: "", // FIXME: Add default user ID here
|
|
Remote: false,
|
|
Location: DefaultDuckLocationName,
|
|
Type: "image/webp",
|
|
Name: "default-duck.webp",
|
|
AltText: "a greyscale image of a pidgeon on some smooth surface, likely a liquid. It is captioned with the text \"Duck\"",
|
|
Blurred: false,
|
|
}
|