model

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

Variables

View Source
var ErrNoPermission = errors.New("no permission")

Functions

func GenAlistServerID added in v0.3.2

func GenAlistServerID(a *AlistVendor)

func GetAlistServerIdFromPath added in v0.3.2

func GetAlistServerIdFromPath(path string) (serverID string, filePath string, err error)

func GetEmbyServerIdFromPath added in v0.3.2

func GetEmbyServerIdFromPath(path string) (serverID string, filePath string, err error)

Types

type AlistStreamingInfo added in v0.3.1

type AlistStreamingInfo struct {
	// {/}serverId/Path
	Path     string `gorm:"type:varchar(4096)" json:"path,omitempty"`
	Password string `gorm:"type:varchar(256)" json:"password,omitempty"`
}

func (*AlistStreamingInfo) AfterFind added in v0.3.1

func (a *AlistStreamingInfo) AfterFind(tx *gorm.DB) error

func (*AlistStreamingInfo) AfterSave added in v0.3.1

func (a *AlistStreamingInfo) AfterSave(tx *gorm.DB) error

func (*AlistStreamingInfo) BeforeSave added in v0.3.1

func (a *AlistStreamingInfo) BeforeSave(tx *gorm.DB) error

func (*AlistStreamingInfo) Validate added in v0.3.2

func (a *AlistStreamingInfo) Validate() error

type AlistVendor added in v0.3.1

type AlistVendor struct {
	CreatedAt      time.Time
	UpdatedAt      time.Time
	UserID         string `gorm:"primaryKey;type:char(32)"`
	Backend        string `gorm:"type:varchar(64)"`
	ServerID       string `gorm:"primaryKey;type:char(32)"`
	Host           string `gorm:"not null;type:varchar(256)"`
	Username       string `gorm:"type:varchar(256)"`
	HashedPassword []byte
}

func (*AlistVendor) AfterFind added in v0.3.1

func (a *AlistVendor) AfterFind(tx *gorm.DB) error

func (*AlistVendor) AfterSave added in v0.3.1

func (a *AlistVendor) AfterSave(tx *gorm.DB) error

func (*AlistVendor) BeforeSave added in v0.3.1

func (a *AlistVendor) BeforeSave(tx *gorm.DB) error

type Backend added in v0.3.1

type Backend struct {
	Endpoint  string `gorm:"primaryKey;type:varchar(512)" json:"endpoint"`
	Comment   string `gorm:"type:text" json:"comment"`
	Tls       bool   `gorm:"default:false" json:"tls"`
	JwtSecret string `gorm:"type:varchar(256)" json:"jwtSecret"`
	CustomCA  string `gorm:"type:text" json:"customCA"`
	TimeOut   string `gorm:"default:10s" json:"timeOut"`

	Consul Consul `gorm:"embedded;embeddedPrefix:consul_" json:"consul"`
	Etcd   Etcd   `gorm:"embedded;embeddedPrefix:etcd_" json:"etcd"`
}

func (*Backend) Validate added in v0.3.1

func (b *Backend) Validate() error

type BackendUsedBy added in v0.3.1

type BackendUsedBy struct {
	Enabled             bool   `gorm:"default:false" json:"enabled"`
	Bilibili            bool   `gorm:"default:false" json:"bilibili"`
	BilibiliBackendName string `gorm:"type:varchar(64)" json:"bilibiliBackendName"`
	Alist               bool   `gorm:"default:false" json:"alist"`
	AlistBackendName    string `gorm:"type:varchar(64)" json:"alistBackendName"`
	Emby                bool   `gorm:"default:false" json:"emby"`
	EmbyBackendName     string `gorm:"type:varchar(64)" json:"embyBackendName"`
}

type BaseMovie

type BaseMovie struct {
	Url        string               `gorm:"type:varchar(8192)" json:"url"`
	Name       string               `gorm:"not null;type:varchar(256)" json:"name"`
	Live       bool                 `json:"live"`
	Proxy      bool                 `json:"proxy"`
	RtmpSource bool                 `json:"rtmpSource"`
	Type       string               `json:"type"`
	Headers    map[string]string    `gorm:"serializer:fastjson;type:text" json:"headers"`
	Subtitles  map[string]*Subtitle `gorm:"serializer:fastjson;type:text" json:"subtitles"`
	VendorInfo VendorInfo           `gorm:"embedded;embeddedPrefix:vendor_info_" json:"vendorInfo,omitempty"`
}

type BilibiliStreamingInfo added in v0.3.1

type BilibiliStreamingInfo struct {
	Bvid    string `json:"bvid,omitempty"`
	Cid     uint64 `json:"cid,omitempty"`
	Epid    uint64 `json:"epid,omitempty"`
	Quality uint64 `json:"quality,omitempty"`
	Shared  bool   `json:"shared,omitempty"`
}

func (*BilibiliStreamingInfo) Validate added in v0.3.1

func (b *BilibiliStreamingInfo) Validate() error

type BilibiliVendor added in v0.3.1

type BilibiliVendor struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	UserID    string            `gorm:"primaryKey;type:char(32)"`
	Backend   string            `gorm:"type:varchar(64)"`
	Cookies   map[string]string `gorm:"not null;serializer:fastjson;type:text"`
}

func (*BilibiliVendor) AfterFind added in v0.3.1

func (b *BilibiliVendor) AfterFind(tx *gorm.DB) error

func (*BilibiliVendor) AfterSave added in v0.3.1

func (b *BilibiliVendor) AfterSave(tx *gorm.DB) error

func (*BilibiliVendor) BeforeSave added in v0.3.1

func (b *BilibiliVendor) BeforeSave(tx *gorm.DB) error

type Consul added in v0.3.1

type Consul struct {
	ServiceName string `gorm:"type:varchar(64)" json:"serviceName"`
	Token       string `gorm:"type:varchar(256)" json:"token"`
	PathPrefix  string `gorm:"type:varchar(64)" json:"pathPrefix"`
	Namespace   string `gorm:"type:varchar(64)" json:"namespace"`
	Partition   string `gorm:"type:varchar(64)" json:"partition"`
}

type EmbyStreamingInfo added in v0.3.1

type EmbyStreamingInfo struct {
	// {/}serverId/ItemId
	Path string `gorm:"type:varchar(52)" json:"path,omitempty"`
}

func (*EmbyStreamingInfo) Validate added in v0.3.2

func (e *EmbyStreamingInfo) Validate() error

type EmbyVendor added in v0.3.1

type EmbyVendor struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	UserID    string `gorm:"primaryKey;type:char(32)"`
	Backend   string `gorm:"type:varchar(64)"`
	ServerID  string `gorm:"primaryKey;type:char(32)"`
	Host      string `gorm:"not null;type:varchar(256)"`
	ApiKey    string `gorm:"not null;type:varchar(256)"`
}

func (*EmbyVendor) AfterFind added in v0.3.1

func (e *EmbyVendor) AfterFind(tx *gorm.DB) error

func (*EmbyVendor) AfterSave added in v0.3.1

func (e *EmbyVendor) AfterSave(tx *gorm.DB) error

func (*EmbyVendor) BeforeSave added in v0.3.1

func (e *EmbyVendor) BeforeSave(tx *gorm.DB) error

type Etcd added in v0.3.1

type Etcd struct {
	ServiceName string `gorm:"type:varchar(64)" json:"serviceName"`
	Username    string `gorm:"type:varchar(64)" json:"username"`
	Password    string `gorm:"type:varchar(256)" json:"password"`
}

type Movie

type Movie struct {
	ID        string    `gorm:"primaryKey;type:char(32)" json:"id"`
	CreatedAt time.Time `json:"-"`
	UpdatedAt time.Time `json:"-"`
	Position  uint      `gorm:"not null" json:"-"`
	RoomID    string    `gorm:"not null;index;type:char(32)" json:"-"`
	CreatorID string    `gorm:"index;type:char(32)" json:"creatorId"`
	Base      BaseMovie `gorm:"embedded;embeddedPrefix:base_" json:"base"`
}

func (*Movie) BeforeCreate

func (m *Movie) BeforeCreate(tx *gorm.DB) error

type Role

type Role uint
const (
	RoleBanned  Role = 1
	RolePending Role = 2
	RoleUser    Role = 3
	RoleAdmin   Role = 4
	RoleRoot    Role = 5
)

func (Role) String

func (r Role) String() string

type Room

type Room struct {
	ID                 string `gorm:"primaryKey;type:char(32)" json:"id"`
	CreatedAt          time.Time
	UpdatedAt          time.Time
	Status             RoomStatus   `gorm:"not null;default:2"`
	Name               string       `gorm:"not null;uniqueIndex;type:varchar(32)"`
	Settings           RoomSettings `gorm:"embedded;embeddedPrefix:settings_"`
	CreatorID          string       `gorm:"index;type:char(32)"`
	HashedPassword     []byte
	GroupUserRelations []RoomUserRelation `gorm:"foreignKey:RoomID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Movies             []Movie            `gorm:"foreignKey:RoomID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (*Room) BeforeCreate

func (r *Room) BeforeCreate(tx *gorm.DB) error

func (*Room) CheckPassword

func (r *Room) CheckPassword(password string) bool

func (*Room) IsActive

func (r *Room) IsActive() bool

func (*Room) IsBanned

func (r *Room) IsBanned() bool

func (*Room) IsPending

func (r *Room) IsPending() bool

func (*Room) NeedPassword

func (r *Room) NeedPassword() bool

type RoomSettings

type RoomSettings struct {
	Hidden                 bool               `json:"hidden"`
	CanCreateMovie         bool               `gorm:"default:true" json:"canCreateMovie"`
	CanEditCurrent         bool               `gorm:"default:true" json:"canEditCurrent"`
	CanSendChat            bool               `gorm:"default:true" json:"canSendChat"`
	DisableJoinNewUser     bool               `gorm:"default:false" json:"disableJoinNewUser"`
	JoinNeedReview         bool               `gorm:"default:false" json:"joinNeedReview"`
	UserDefaultPermissions RoomUserPermission `json:"userDefaultPermissions"`
}

type RoomStatus

type RoomStatus uint64
const (
	RoomStatusBanned  RoomStatus = 1
	RoomStatusPending RoomStatus = 2
	RoomStatusActive  RoomStatus = 3
)

func (RoomStatus) String

func (r RoomStatus) String() string

type RoomUserPermission

type RoomUserPermission uint64
const (
	PermissionAll      RoomUserPermission = 0xffffffff
	PermissionEditRoom RoomUserPermission = 1 << iota
	PermissionEditUser
	PermissionCreateMovie
	PermissionEditCurrent
	PermissionSendChat
)

func (RoomUserPermission) Has

func (p RoomUserPermission) Has(permission RoomUserPermission) bool

type RoomUserRelation

type RoomUserRelation struct {
	CreatedAt   time.Time
	UpdatedAt   time.Time
	UserID      string         `gorm:"primarykey;type:char(32)"`
	RoomID      string         `gorm:"primarykey;type:char(32)"`
	Status      RoomUserStatus `gorm:"not null;default:2"`
	Permissions RoomUserPermission
}

func (*RoomUserRelation) HasPermission

func (r *RoomUserRelation) HasPermission(permission RoomUserPermission) bool

type RoomUserStatus

type RoomUserStatus uint64
const (
	RoomUserStatusBanned RoomUserStatus = iota + 1
	RoomUserStatusPending
	RoomUserStatusActive
)

func (RoomUserStatus) String

func (r RoomUserStatus) String() string

type Setting

type Setting struct {
	Name      string `gorm:"primaryKey;type:varchar(256)"`
	UpdatedAt time.Time
	Value     string       `gorm:"not null;type:text"`
	Type      SettingType  `gorm:"not null;default:string"`
	Group     SettingGroup `gorm:"not null"`
}

type SettingGroup

type SettingGroup string
const (
	SettingGroupRoom     SettingGroup = "room"
	SettingGroupUser     SettingGroup = "user"
	SettingGroupProxy    SettingGroup = "proxy"
	SettingGroupRtmp     SettingGroup = "rtmp"
	SettingGroupDatabase SettingGroup = "database"
	SettingGroupServer   SettingGroup = "server"
	SettingGroupOauth2   SettingGroup = "oauth2"
)

func (SettingGroup) String

func (s SettingGroup) String() string

type SettingType

type SettingType string
const (
	SettingTypeBool    SettingType = "bool"
	SettingTypeInt64   SettingType = "int64"
	SettingTypeFloat64 SettingType = "float64"
	SettingTypeString  SettingType = "string"
)

type Subtitle added in v0.3.1

type Subtitle struct {
	URL  string `json:"url"`
	Type string `json:"type"`
}

type User

type User struct {
	ID                   string `gorm:"primaryKey;type:char(32)" json:"id"`
	CreatedAt            time.Time
	UpdatedAt            time.Time
	RegisteredByProvider bool               `gorm:"not null;default:false"`
	UserProviders        []UserProvider     `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Username             string             `gorm:"not null;uniqueIndex;type:varchar(32)"`
	HashedPassword       []byte             `gorm:"not null"`
	Role                 Role               `gorm:"not null;default:2"`
	RoomUserRelations    []RoomUserRelation `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Rooms                []Room             `gorm:"foreignKey:CreatorID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	Movies               []Movie            `gorm:"foreignKey:CreatorID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	BilibiliVendor       *BilibiliVendor    `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	AlistVendor          []*AlistVendor     `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	EmbyVendor           []*EmbyVendor      `gorm:"foreignKey:UserID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) error

func (*User) CheckPassword

func (u *User) CheckPassword(password string) bool

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) IsBanned

func (u *User) IsBanned() bool

func (*User) IsPending

func (u *User) IsPending() bool

func (*User) IsRoot

func (u *User) IsRoot() bool

func (*User) IsUser

func (u *User) IsUser() bool

type UserProvider

type UserProvider struct {
	Provider       provider.OAuth2Provider `gorm:"primarykey;type:varchar(32);uniqueIndex:idx_provider_user_id"`
	ProviderUserID string                  `gorm:"primarykey;type:varchar(64)"`
	CreatedAt      time.Time
	UpdatedAt      time.Time
	UserID         string `gorm:"not null;type:char(32);uniqueIndex:idx_provider_user_id"`
}

type VendorBackend added in v0.3.1

type VendorBackend struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	Backend   Backend       `gorm:"embedded;embeddedPrefix:backend_" json:"backend"`
	UsedBy    BackendUsedBy `gorm:"embedded;embeddedPrefix:used_by_" json:"usedBy"`
}

func (*VendorBackend) AfterFind added in v0.3.1

func (v *VendorBackend) AfterFind(tx *gorm.DB) error

func (*VendorBackend) AfterSave added in v0.3.1

func (v *VendorBackend) AfterSave(tx *gorm.DB) error

func (*VendorBackend) BeforeSave added in v0.3.1

func (v *VendorBackend) BeforeSave(tx *gorm.DB) error

type VendorInfo

type VendorInfo struct {
	Vendor   VendorName             `gorm:"type:varchar(32)" json:"vendor"`
	Backend  string                 `gorm:"type:varchar(64)" json:"backend"`
	Bilibili *BilibiliStreamingInfo `gorm:"embedded;embeddedPrefix:bilibili_" json:"bilibili,omitempty"`
	Alist    *AlistStreamingInfo    `gorm:"embedded;embeddedPrefix:alist_" json:"alist,omitempty"`
	Emby     *EmbyStreamingInfo     `gorm:"embedded;embeddedPrefix:emby_" json:"emby,omitempty"`
}

type VendorName added in v0.3.1

type VendorName = string
const (
	VendorBilibili VendorName = "bilibili"
	VendorAlist    VendorName = "alist"
	VendorEmby     VendorName = "emby"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL