77 lines
2.0 KiB
Go
77 lines
2.0 KiB
Go
package database
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type MediaType string
|
|
|
|
const (
|
|
Video MediaType = "video"
|
|
Presentation MediaType = "presentation"
|
|
Internet MediaType = "internet"
|
|
Unspecified MediaType = "unspecified"
|
|
)
|
|
|
|
type Timestamps struct {
|
|
CreatedAt time.Time `gorm:"not null;"`
|
|
UpdatedAt time.Time `gorm:"not null;"`
|
|
ExpiresAt time.Time
|
|
}
|
|
|
|
type State struct {
|
|
ID int `gorm:"primaryKey;not null;"`
|
|
// unspecified
|
|
// video
|
|
// presentation
|
|
// internet URL
|
|
MediaType MediaType `gorm:"type:varchar(20);not null"` // Must specify what kind of file it is
|
|
// Must be target list who are compelled to listen to the command
|
|
// can be none when there is no targets specified (init stage)
|
|
Targets []string `gorm:"type:json"`
|
|
// Must be the location where the file is downloadable on the API
|
|
// can be none when there is no media specified (init stage)
|
|
Location string
|
|
Timestamps
|
|
}
|
|
|
|
type Key struct {
|
|
ID int `gorm:"primaryKey;not null;"`
|
|
MetaName string
|
|
KeyName string `gorm:"not null;"`
|
|
// We don't store the key itself, we hash the key
|
|
KeyHash string `gorm:"not null;"`
|
|
// we're cooking without pepper
|
|
KeySalt string `gorm:"not null;"`
|
|
CreatedAt time.Time `gorm:"not null;"`
|
|
Timestamps
|
|
}
|
|
|
|
type Device struct {
|
|
ID int `gorm:"primaryKey;not null;"`
|
|
// Device type is meant as a field where can be specified what type of device this is
|
|
// eg Raspberry Pi, PC, things like that
|
|
DeviceType string
|
|
Hostname string `gorm:"not null;"`
|
|
RemoteAddress string `gorm:"not null;"`
|
|
Alive bool `gorm:"not null;"`
|
|
Compliant bool `gorm:"not null;"`
|
|
Timestamps
|
|
}
|
|
|
|
type File struct {
|
|
ID int `gorm:"primaryKey;not null;"`
|
|
// unspecified
|
|
// video
|
|
// presentation
|
|
// internet URL
|
|
MediaType MediaType `gorm:"type:varchar(20);not null;"`
|
|
// the name given by the user
|
|
MetaName string
|
|
FileName string `gorm:"not null;"`
|
|
FilePath string `gorm:"not null;"`
|
|
// hex encoded sha512 checksum
|
|
Checksum string `gorm:"uniqueIndex;not null;"`
|
|
Timestamps
|
|
}
|