39 lines
1.5 KiB
Go
39 lines
1.5 KiB
Go
package storage
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// MediaMetadata contains metadata about some media
|
|
// Metadata includes whether it's a remote file or not, what the name is,
|
|
// the MIME type, and an identifier pointing to its location
|
|
type MediaMetadata 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
|
|
// Where the media is stored. Url if remote file,
|
|
Location string
|
|
Type string // What media type this is following mime types, eg image/png
|
|
// Descriptive name for a media file
|
|
// Emote name for example or servername.filetype for a server's icon
|
|
Name string
|
|
}
|
|
|
|
// TODO: Figure out how to actually manage media. Because this current idea sucks
|
|
// One idea would be to make another storage provider, but purely focused on handling the files
|
|
// and then using this section to store metadata about the files it knows
|
|
func (s *Storage) NewMediaMetadata(url, mediaType, name string) (*MediaMetadata, error) {
|
|
newMedia := MediaMetadata{
|
|
Location: url,
|
|
Name: name,
|
|
}
|
|
s.db.Create(&newMedia)
|
|
return nil, nil
|
|
}
|