linstrom/storage/mediaFile.go
2024-09-12 16:57:53 +02:00

36 lines
1.7 KiB
Go

package storage
import (
"time"
"gorm.io/gorm"
)
// MediaFile represents a file containing some media
// This media may be stored locally via a file system or S3 bucket
// or remote on a different server
// Additionally, it contains some useful data for more easily working with it
type MediaFile struct {
ID string `gorm:"primarykey"` // 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"`
Remote bool // whether the attachment is a remote one
// Always an url, either an absolute path to a local file or an url to a remote file
Link string
Type string // What media type this is following mime types, eg image/png
// Whether this media has been cached locally
// Used for user and server icons as well as emotes, not attachments
// If true, Link will be read as file path. url otherwise
// Reason: Attachments would take way to much space considering that they are often only loaded a few times at most
// And caching a file for those few times would be a waste of storage
// Caching user and server icons locally however should reduce burden on remote servers by quite a bit though
// TODO: Decide later during usage if attachment caching would be a good idea
LocallyCached bool
// Descriptive name for a media file
// Emote name for example or servername.filetype for a server's icon
Name string
}