2024-05-31 09:54:39 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
2024-09-12 14:57:53 +00:00
|
|
|
// 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
|
2024-05-31 09:54:39 +00:00
|
|
|
type MediaFile struct {
|
2024-08-28 15:20:38 +00:00
|
|
|
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
|
2024-06-06 11:54:50 +00:00
|
|
|
// 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
|
2024-05-31 09:54:39 +00:00
|
|
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
|
|
|
Remote bool // whether the attachment is a remote one
|
2024-09-12 14:57:53 +00:00
|
|
|
// 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
|
2024-05-31 09:54:39 +00:00
|
|
|
// Whether this media has been cached locally
|
2024-09-12 14:57:53 +00:00
|
|
|
// Used for user and server icons as well as emotes, not attachments
|
2024-05-31 15:21:29 +00:00
|
|
|
// If true, Link will be read as file path. url otherwise
|
2024-05-31 09:54:39 +00:00
|
|
|
// 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
|
2024-09-12 14:57:53 +00:00
|
|
|
// TODO: Decide later during usage if attachment caching would be a good idea
|
2024-05-31 09:54:39 +00:00
|
|
|
LocallyCached bool
|
2024-09-12 14:57:53 +00:00
|
|
|
// Descriptive name for a media file
|
|
|
|
// Emote name for example or servername.filetype for a server's icon
|
|
|
|
Name string
|
2024-05-31 09:54:39 +00:00
|
|
|
}
|