model

package
v1.1.18 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FILETYPE_INVALID = iota
	FILETYPE_VOD
	FILETYPE_ATTACHMENT
	FILETYPE_IMAGE_JPG
	FILETYPE_THUMB_COMB
	FILETYPE_THUMB_CAM
	FILETYPE_THUMB_PRES
)
View Source
const (
	TargetAll      = iota + 1 //TargetAll Is any user, regardless if logged in or not
	TargetUser                //TargetUser Are all users that are logged in
	TargetStudent             //TargetStudent Are all users that are logged in and are students
	TargetLecturer            //TargetLecturer Are all users that are logged in and are lecturers
	TargetAdmin               //TargetAdmin Are all users that are logged in and are admins

)
View Source
const (
	AdminType    = 1
	LecturerType = 2
	GenericType  = 3
	StudentType  = 4
)
View Source
const TokenScopeAdmin = "admin"

Variables

View Source
var (
	ErrReplyToReply       = errors.New("reply to reply not allowed")
	ErrReplyToWrongStream = errors.New("reply to message from different stream not allowed")
	ErrReplyToNoMsg       = errors.New("reply to message not found")

	ErrMessageTooLong = errors.New("message too long")
	ErrMessageNoText  = errors.New("message has no text")
	ErrCooledDown     = errors.New("user is cooled down")
)
View Source
var (
	ErrInvalidHash         = errors.New("the encoded hash is not in the correct format")
	ErrIncompatibleVersion = errors.New("incompatible version of argon2")
)

Functions

func GenerateFromPassword

func GenerateFromPassword(password string) (encodedHash string, err error)

func ParsableTimeFormat added in v1.1.2

func ParsableTimeFormat(time time.Time) string

ParsableTimeFormat returns a JavaScript friendly formatted date string

Types

type Audit added in v1.0.8

type Audit struct {
	gorm.Model

	User    *User // if nil -> system
	UserID  *uint
	Message string
	Type    AuditType
}

func (Audit) Json added in v1.0.8

func (a Audit) Json() gin.H

Json converts the audit into a json object consumed by apis

type AuditType added in v1.0.8

type AuditType uint
const (
	AuditInfo AuditType = iota + 1
	AuditWarning
	AuditError
	AuditCourseCreate
	AuditCourseEdit
	AuditCourseDelete
	AuditStreamCreate
	AuditStreamEdit
	AuditStreamDelete
	AuditCameraMoved
)

func GetAllAuditTypes added in v1.0.8

func GetAllAuditTypes() []AuditType

func (AuditType) String added in v1.0.8

func (t AuditType) String() string

String returns a string representation of the AuditType

type Bookmark added in v1.1.1

type Bookmark struct {
	gorm.Model

	Description string `gorm:"not null" json:"description"`
	Hours       uint   `gorm:"not null" json:"hours"`
	Minutes     uint   `gorm:"not null" json:"minutes"`
	Seconds     uint   `gorm:"not null" json:"seconds"`
	UserID      uint   `gorm:"not null" json:"-"`
	StreamID    uint   `gorm:"not null" json:"-"`
}

type CameraPreset

type CameraPreset struct {
	Name          string `gorm:"not null"`
	PresetID      int    `gorm:"primaryKey;autoIncrement:false"`
	Image         string
	LectureHallID uint `gorm:"primaryKey;autoIncrement:false"`
	IsDefault     bool // this will be selected if there's no preference
}

type CameraPresetPreference

type CameraPresetPreference struct {
	LectureHallID uint `json:"lecture_hall_id"`
	PresetID      int  `json:"preset_id"`
}

type CameraType added in v1.0.6

type CameraType uint
const (
	Axis CameraType = iota + 1
	Panasonic
)

type Chat

type Chat struct {
	gorm.Model

	UserID           string `gorm:"not null" json:"-"`
	UserName         string `gorm:"not null" json:"name"`
	Message          string `gorm:"type:text;not null;index:,class:FULLTEXT" json:"-"`
	SanitizedMessage string `gorm:"-" json:"message"` // don't store the sanitized message in the database
	StreamID         uint   `gorm:"not null" json:"-"`
	Admin            bool   `gorm:"not null;default:false" json:"admin"`
	Color            string `gorm:"not null;default:'#368bd6'" json:"color"`

	Visible   sql.NullBool `gorm:"not null;default:true" json:"-"`
	IsVisible bool         `gorm:"-" json:"visible"` // IsVisible is .Bool value of Visible for simplicity

	Likes     int    `gorm:"-" json:"likes"`
	Liked     bool   `gorm:"-" json:"liked"`
	UserLikes []User `gorm:"many2many:chat_user_likes" json:"-"`

	AddressedToUsers []User `gorm:"many2many:chat_user_addressedto" json:"-"`
	AddressedToIds   []uint `gorm:"-" json:"addressedTo"`

	Replies []Chat        `gorm:"foreignkey:ReplyTo" json:"replies"`
	ReplyTo sql.NullInt64 `json:"replyTo"`

	Resolved bool `gorm:"not null;default:false" json:"resolved"`
}

func (*Chat) AfterFind

func (c *Chat) AfterFind(_ *gorm.DB) (err error)

AfterFind is a GORM hook that sanitizes the message after it's loaded from the database.

func (*Chat) BeforeCreate

func (c *Chat) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate is a GORM hook that is called before a new chat is created. Messages won't be saved if any of these apply: - message is empty (after trimming) - message is too long (>maxMessageLength) - user is cooled down (user sent > coolDownMessages messages within coolDown) - message is a reply, and:

  • reply is to a reply (not allowed)
  • reply is to a message from a different stream
  • reply is to a message that doesn't exist

func (*Chat) SanitiseMessage

func (c *Chat) SanitiseMessage()

SanitiseMessage sets chat.SanitizedMessage to the sanitized html version of chat.Message, including <a> tags for links

type Course

type Course struct {
	gorm.Model

	UserID                  uint   `gorm:"not null"` // Owner of the course
	Name                    string `gorm:"not null"`
	Slug                    string `gorm:"not null"` // eg. eidi
	Year                    int    `gorm:"not null"` // eg. 2021
	TeachingTerm            string `gorm:"not null"` // eg. Summer/Winter
	TUMOnlineIdentifier     string
	VODEnabled              bool `gorm:"default:true"`
	DownloadsEnabled        bool `gorm:"default:false"`
	ChatEnabled             bool `gorm:"default:false"`
	AnonymousChatEnabled    bool `gorm:"not null;default:true"`
	ModeratedChatEnabled    bool `gorm:"not null;default:false"`
	VodChatEnabled          bool
	Visibility              string `gorm:"default:loggedin"` // public, loggedin or enrolled
	Streams                 []Stream
	Users                   []User `gorm:"many2many:course_users;"`
	Admins                  []User `gorm:"many2many:course_admins;"`
	Token                   string
	UserCreatedByToken      bool   `gorm:"default:false"`
	CameraPresetPreferences string // json encoded. e.g. [{lectureHallID:1, presetID:4}, ...]
	SourcePreferences       string // json encoded. e.g. [{lectureHallID:1, sourceMode:0}, ...]
	Pinned                  bool   `gorm:"-"` // Used to determine if the course is pinned when loaded for a specific user.
}

func (Course) AdminJson added in v1.0.5

func (c Course) AdminJson(lhs []LectureHall) []gin.H

AdminJson is the JSON representation of a courses streams for the admin panel

func (Course) CanUseSource added in v1.1.8

func (c Course) CanUseSource(lectureHallID uint, sourceType string) bool

CanUseSource returns whether the specified source type is allowed for the lecture hall id given

func (Course) CompareTo

func (c Course) CompareTo(other Course) bool

CompareTo used for sorting. Falling back to old java habits...

func (Course) GetCameraPresetPreference

func (c Course) GetCameraPresetPreference() []CameraPresetPreference

GetCameraPresetPreference retrieves the camera preset preferences

func (Course) GetLiveStreams added in v1.0.4

func (c Course) GetLiveStreams() []Stream

GetLiveStreams returns the current live streams of the course or an empty slice if none are live

func (Course) GetNextLecture

func (c Course) GetNextLecture() Stream

GetNextLecture returns the next lecture of the course

func (Course) GetNextLectureDate

func (c Course) GetNextLectureDate() time.Time

GetNextLectureDate returns the next lecture date of the course

func (Course) GetNextLectureDateFormatted

func (c Course) GetNextLectureDateFormatted() string

GetNextLectureDateFormatted returns a JavaScript friendly formatted date string

func (Course) GetRecordings

func (c Course) GetRecordings() []Stream

GetRecordings returns all recording of this course as streams

func (Course) GetSourceModeForLectureHall added in v1.1.8

func (c Course) GetSourceModeForLectureHall(id uint) SourceMode

GetSourceModeForLectureHall retrieves the source preference for the given lecture hall, returns default SourcePreference if non-existing

func (Course) GetSourcePreference added in v1.1.8

func (c Course) GetSourcePreference() []SourcePreference

GetSourcePreference retrieves the source preferences

func (Course) GetStreamUrl added in v1.0.3

func (c Course) GetStreamUrl(stream Stream) string

GetStreamUrl returns the URL of the stream, e.g. /w/MyStream/42

func (Course) GetUrl added in v1.0.3

func (c Course) GetUrl() string

GetUrl returns the URL of the course, e.g. /course/2022/S/MyCourse

func (Course) HasNextLecture

func (c Course) HasNextLecture() bool

HasNextLecture checks whether there is another upcoming lecture

func (Course) HasRecordings

func (c Course) HasRecordings() bool

HasRecordings returns whether the course has any recordings.

func (Course) HasStreams added in v1.0.4

func (c Course) HasStreams() bool

HasStreams checks whether the lecture has any streams (recorded, live or upcoming) associated to it

func (Course) IsHidden

func (c Course) IsHidden() bool

IsHidden returns true if visibility is set to 'hidden' and false if not

func (Course) IsLive

func (c Course) IsLive() bool

IsLive returns whether the course has a lecture that is live

func (Course) IsNextLectureSelfStream

func (c Course) IsNextLectureSelfStream() bool

IsNextLectureSelfStream checks whether the next lecture is a self stream

func (Course) IsNextLectureStartingSoon

func (c Course) IsNextLectureStartingSoon() bool

IsNextLectureStartingSoon checks whether the course has a lecture that starts soon

func (Course) NextLectureHasReachedTimeSlot

func (c Course) NextLectureHasReachedTimeSlot() bool

NextLectureHasReachedTimeSlot returns whether the courses next lecture arrived at its timeslot

func (Course) NumStreams

func (c Course) NumStreams() int

NumStreams returns the number of streams for the course that are VoDs or live

func (Course) NumUsers

func (c Course) NumUsers() int

NumUsers returns the number of users enrolled in the course

func (*Course) SetCameraPresetPreference

func (c *Course) SetCameraPresetPreference(pref []CameraPresetPreference)

SetCameraPresetPreference updates the camera preset preferences

func (*Course) SetSourcePreference added in v1.1.8

func (c *Course) SetSourcePreference(pref []SourcePreference)

SetSourcePreference updates the source preferences

type File

type File struct {
	gorm.Model

	StreamID uint   `gorm:"not null"`
	Path     string `gorm:"not null"`
	Filename string
	Type     FileType `gorm:"not null; default: 1"`
}

func (File) GetDownloadFileName

func (f File) GetDownloadFileName() string

func (File) GetFriendlyFileName

func (f File) GetFriendlyFileName() string

func (File) IsThumb added in v1.0.6

func (f File) IsThumb() bool

func (File) IsURL added in v1.0.6

func (f File) IsURL() bool

type FileType added in v1.0.6

type FileType uint

type InfoPage added in v1.0.6

type InfoPage struct {
	gorm.Model

	Name       string       `gorm:"not null"` // e.g. 'privacy', 'imprint',...
	RawContent string       `gorm:"text; not null"`
	Type       InfoPageType `gorm:"not null; default: 1"`
}

func (InfoPage) Render added in v1.0.6

func (mt InfoPage) Render() template.HTML

type InfoPageType added in v1.0.6

type InfoPageType uint
const (
	INFOPAGE_MARKDOWN InfoPageType = iota + 1
)

type IngestServer

type IngestServer struct {
	gorm.Model  `json:"gorm_model"`
	Url         string       `json:"url"`                // e.g. rtmp://user:password@ingest1.huge.server.com
	OutUrl      string       `gorm:"not null"`           // e.g. https://out.server.com/streams/%s/playlist.m3u8 where %s is the stream name
	Workload    int          `json:"workload,omitempty"` // # of streams currently ingesting to this server
	StreamNames []StreamName // array of stream names that will be assigned to this server
}

IngestServer represents a server we ingest our streams to. This is used for load balancing.

type Keyword added in v1.1.0

type Keyword struct {
	gorm.Model

	StreamID uint   `gorm:"not null"`
	Text     string `gorm:"text;not null;index:,class:FULLTEXT"`
	Valid    bool   `gorm:"not null; default: 1"`
}

type LectureHall

type LectureHall struct {
	gorm.Model

	Name           string `gorm:"not null"` //as in smp (e.g. room_00_13_009A)
	FullName       string `gorm:"not null"` //e.g. '5613.EG.009A (00.13.009A, Seminarraum), Boltzmannstr. 3(5613), 85748 Garching b. München'
	CombIP         string
	PresIP         string
	CamIP          string
	CameraIP       string     // ip of the actual camera (not smp)
	CameraType     CameraType `gorm:"not null; default:1"`
	Streams        []Stream
	CameraPresets  []CameraPreset
	RoomID         int    // used by TUMOnline
	PwrCtrlIp      string // power control api for red live light
	LiveLightIndex int    // id of power outlet for live light
}

func (LectureHall) NumSources

func (l LectureHall) NumSources() int

type Model

type Model struct {
	ID        uint           `gorm:"primarykey" json:"id"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"-"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

Model is a base model that can be embedded in other models it's basically the same as gorm.Model but with convenient json annotations

type Notification

type Notification struct {
	Model

	Title  *string            `json:"title,omitempty"`
	Body   string             `json:"-" gorm:"not null"`
	Target NotificationTarget `json:"-" gorm:"not null; default:1"`

	// SanitizedBody is the body of the notification, converted from markdown to HTML
	SanitizedBody string `json:"body" gorm:"-"`
}

Notification is a message (e.g. a feature alert) that is displayed to users

func (*Notification) AfterFind

func (n *Notification) AfterFind(_ *gorm.DB) error

AfterFind populates the SanitizedBody after getting the Notification from the database

func (Notification) GetBodyForGoTemplate

func (n Notification) GetBodyForGoTemplate() template.HTML

type NotificationTarget

type NotificationTarget int

NotificationTarget is a User group the Notification is displayed to

type PlaybackSpeedSetting added in v1.0.6

type PlaybackSpeedSetting struct {
	Speed   float32 `json:"speed"`
	Enabled bool    `json:"enabled"`
}

type PlaybackSpeedSettings added in v1.0.6

type PlaybackSpeedSettings []PlaybackSpeedSetting

func (PlaybackSpeedSettings) GetEnabled added in v1.0.6

func (s PlaybackSpeedSettings) GetEnabled() (res []float32)

type Poll

type Poll struct {
	gorm.Model

	StreamID uint   // used by gorm
	Stream   Stream `gorm:"foreignKey:stream_id;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Question string `gorm:"not null" json:"question"`
	Active   bool   `gorm:"not null;default:true" json:"active"`

	PollOptions []PollOption `gorm:"many2many:chat_poll_options" json:"pollOptions"`
}

type PollOption

type PollOption struct {
	gorm.Model

	Answer string `gorm:"not null" json:"answer"`
	Votes  []User `gorm:"many2many:poll_option_user_votes" json:"-"`
}

func (PollOption) GetStatsMap

func (o PollOption) GetStatsMap(votes int64) gin.H
type RegisterLink struct {
	gorm.Model

	UserID         uint   `gorm:"not null"`
	RegisterSecret string `gorm:"not null"`
}

type ServerNotification

type ServerNotification struct {
	gorm.Model

	Text    string    `gorm:"not null"`
	Warn    bool      `gorm:"not null;default:false"` // if false -> Info
	Start   time.Time `gorm:"not null"`
	Expires time.Time `gorm:"not null"`
}

ServerNotification todo: rename to ServerAlert to avoid confusion with Notification

func (ServerNotification) BeforeCreate

func (s ServerNotification) BeforeCreate(tx *gorm.DB) (err error)

func (ServerNotification) FormatExpires

func (s ServerNotification) FormatExpires() string

func (ServerNotification) FormatFrom

func (s ServerNotification) FormatFrom() string
type ShortLink struct {
	gorm.Model

	Link     string `gorm:"type:varchar(256); unique; not null"`
	CourseId uint   `gorm:"not null"`
}

ShortLink friendly name for a link to courses highlight page

type Silence

type Silence struct {
	gorm.Model `json:"omitempty"`

	Start    uint `json:"start"`
	End      uint `json:"end"`
	StreamID uint `json:"stream_id,omitempty"`
}

type SourceMode added in v1.1.8

type SourceMode int

SourceMode 0 -> COMB, 1-> PRES, 2 -> CAM

type SourcePreference added in v1.1.8

type SourcePreference struct {
	LectureHallID uint       `json:"lecture_hall_id"`
	SourceMode    SourceMode `json:"source_mode"`
}

type Stat

type Stat struct {
	gorm.Model

	Time     time.Time `gorm:"not null"`
	StreamID uint      `gorm:"not null"`
	Viewers  uint      `gorm:"not null;default:0"`
	Live     bool      `gorm:"not null;default:false"`
}

type Stream

type Stream struct {
	gorm.Model

	Name                  string `gorm:"index:,class:FULLTEXT"`
	Description           string `gorm:"type:text;index:,class:FULLTEXT"`
	CourseID              uint
	Start                 time.Time `gorm:"not null"`
	End                   time.Time `gorm:"not null"`
	ChatEnabled           bool      `gorm:"default:null"`
	RoomName              string
	RoomCode              string
	EventTypeName         string
	TUMOnlineEventID      uint
	SeriesIdentifier      string `gorm:"default:null"`
	StreamKey             string `gorm:"not null"`
	PlaylistUrl           string
	PlaylistUrlPRES       string
	PlaylistUrlCAM        string
	LiveNow               bool      `gorm:"not null"`
	LiveNowTimestamp      time.Time `gorm:"default:null;column:live_now_timestamp"`
	Recording             bool
	Premiere              bool `gorm:"default:null"`
	Ended                 bool `gorm:"default:null"`
	Chats                 []Chat
	Stats                 []Stat
	Units                 []StreamUnit
	VodViews              uint `gorm:"default:0"` // todo: remove me before next semester
	StartOffset           uint `gorm:"default:null"`
	EndOffset             uint `gorm:"default:null"`
	LectureHallID         uint `gorm:"default:null"`
	Silences              []Silence
	Files                 []File `gorm:"foreignKey:StreamID"`
	ThumbInterval         uint32 `gorm:"default:null"`
	Paused                bool   `gorm:"default:false"`
	StreamName            string
	Duration              uint32           `gorm:"default:null"`
	StreamWorkers         []Worker         `gorm:"many2many:stream_workers;"`
	StreamProgresses      []StreamProgress `gorm:"foreignKey:StreamID"`
	VideoSections         []VideoSection
	TranscodingProgresses []TranscodingProgress `gorm:"foreignKey:StreamID"`
	Private               bool                  `gorm:"not null;default:false"`

	Watched bool `gorm:"-"` // Used to determine if stream is watched when loaded for a specific user.
}

func (Stream) Attachments added in v1.0.6

func (s Stream) Attachments() []File

func (Stream) Color added in v1.0.4

func (s Stream) Color() string

Color returns the ui color of the stream that indicates it's status

func (Stream) FriendlyDate

func (s Stream) FriendlyDate() string

func (Stream) FriendlyNextDate

func (s Stream) FriendlyNextDate() string

func (Stream) FriendlyTime

func (s Stream) FriendlyTime() string

func (Stream) GetDescriptionHTML

func (s Stream) GetDescriptionHTML() string

func (Stream) GetName added in v1.0.3

func (s Stream) GetName() string

func (Stream) GetSilencesJson

func (s Stream) GetSilencesJson() string

func (Stream) GetStartInSeconds added in v1.0.3

func (s Stream) GetStartInSeconds() int

GetStartInSeconds returns the number of seconds until the stream starts (or 0 if it has already started or is a vod)

func (Stream) GetThumbIdForSource added in v1.0.6

func (s Stream) GetThumbIdForSource(source string) uint

GetThumbIdForSource returns the id of file that stores the thumbnail sprite for a specific source type.

func (Stream) GetVodFiles added in v1.0.6

func (s Stream) GetVodFiles() []File

GetVodFiles returns all downloadable files that user can see when using the download dropdown for a stream.

func (Stream) IsComingUp

func (s Stream) IsComingUp() bool

IsComingUp returns whether the stream begins in 30 minutes

func (Stream) IsConverting added in v1.0.3

func (s Stream) IsConverting() bool

func (Stream) IsDownloadable

func (s Stream) IsDownloadable() bool

IsDownloadable returns true if the stream is a recording and has at least one file associated with it.

func (Stream) IsPast

func (s Stream) IsPast() bool

IsPast returns whether the stream end time was reached

func (Stream) IsPlanned

func (s Stream) IsPlanned() bool

IsPlanned returns whether the stream is planned or not

func (Stream) IsSelfStream

func (s Stream) IsSelfStream() bool

IsSelfStream returns whether the stream is a scheduled stream in a lecture hall

func (Stream) IsStartingInMoreThanOneDay

func (s Stream) IsStartingInMoreThanOneDay() bool

IsStartingInMoreThanOneDay returns whether the stream starts in at least 2 days

func (Stream) IsStartingInOneDay

func (s Stream) IsStartingInOneDay() bool

IsStartingInOneDay returns whether the stream starts within 1 day

func (Stream) ParsableLiveNowTimestamp added in v1.1.2

func (s Stream) ParsableLiveNowTimestamp() string

ParsableLiveNowTimestamp returns a JavaScript friendly formatted date string

func (Stream) ParsableStartTime added in v1.1.2

func (s Stream) ParsableStartTime() string

ParsableStartTime returns a JavaScript friendly formatted date string

func (Stream) TimeSlotReached

func (s Stream) TimeSlotReached() bool

TimeSlotReached returns whether stream has passed the starting time

type StreamName

type StreamName struct {
	gorm.Model

	StreamName     string    `gorm:"type:varchar(64); unique; not null"`
	IsTranscoding  bool      `gorm:"not null;default:false"`
	IngestServerID uint      `gorm:"not null"`
	StreamID       uint      // Is null when the slot is not used
	FreedAt        time.Time `gorm:"not null;default:0"`
}

StreamName is essentially a "streaming slot" used for load balancing

type StreamProgress

type StreamProgress struct {
	Progress float64 `gorm:"not null"`               // The progress of the stream as represented as a floating point value between 0 and 1.
	Watched  bool    `gorm:"not null;default:false"` // Whether the user has marked the stream as watched.

	// We need to use a primary key in order to use ON CONFLICT in dao/progress.go, same as e.g. https://www.sqlite.org/lang_conflict.html.
	StreamID uint `gorm:"primaryKey"`
	UserID   uint `gorm:"primaryKey"`
}

StreamProgress represents the progress of a stream or video. Currently, it is only used for VoDs.

type StreamUnit

type StreamUnit struct {
	gorm.Model

	UnitName        string
	UnitDescription string
	UnitStart       uint `gorm:"not null"`
	UnitEnd         uint `gorm:"not null"`
	StreamID        uint `gorm:"not null"`
}

func (StreamUnit) GetDescriptionHTML

func (s StreamUnit) GetDescriptionHTML() template.HTML

func (StreamUnit) GetRoundedUnitLen

func (s StreamUnit) GetRoundedUnitLen() string

func (StreamUnit) GetUnitDurationMS

func (s StreamUnit) GetUnitDurationMS() uint

type StreamVersion added in v1.1.1

type StreamVersion string
const (
	COMB StreamVersion = "COMB"
	CAM  StreamVersion = "CAM"
	PRES StreamVersion = "PRES"
)

type Token

type Token struct {
	gorm.Model
	UserID  uint         // used by gorm
	User    User         `gorm:"foreignKey:user_id;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` // creator of the token
	Token   string       `json:"token" gorm:"not null"`                                                     // secret token
	Expires sql.NullTime `json:"expires"`                                                                   // expiration date (null if none)
	Scope   string       `json:"scope" gorm:"not null"`                                                     // scope of the token, currently only admin
	LastUse sql.NullTime `json:"last_use"`                                                                  // last time the token was used
}

Token can be used to authenticate instead of a user account

type TranscodingProgress added in v1.1.1

type TranscodingProgress struct {
	StreamID uint          `gorm:"primaryKey" json:"streamID"`
	Version  StreamVersion `gorm:"primaryKey" json:"version"`

	Progress int `gorm:"not null; default:0" json:"progress"`
}

TranscodingProgress is the progress as a percentage of the conversion of a single stream view (e.g. stream 123, COMB view)

type UploadKey added in v1.0.3

type UploadKey struct {
	gorm.Model
	UploadKey string `gorm:"not null"`
	Stream    Stream
	StreamID  uint
}

UploadKey represents a key that is created when a user uploads a file, sent to the worker with the upload request and back to TUM-Live to authenticate the request.

type User

type User struct {
	gorm.Model

	Name                string         `gorm:"not null" json:"name"`
	LastName            *string        `json:"-"`
	Email               sql.NullString `gorm:"type:varchar(256); uniqueIndex; default:null" json:"-"`
	MatriculationNumber string         `gorm:"type:varchar(256); uniqueIndex; default:null" json:"-"`
	LrzID               string         `json:"-"`
	Role                uint           `gorm:"default:4" json:"-"` // AdminType = 1, LecturerType = 2, GenericType = 3, StudentType  = 4
	Password            string         `gorm:"default:null" json:"-"`
	Courses             []Course       `gorm:"many2many:course_users" json:"-"` // courses a lecturer invited this user to
	AdministeredCourses []Course       `gorm:"many2many:course_admins"`         // courses this user is an admin of
	PinnedCourses       []Course       `gorm:"many2many:pinned_courses"`

	Settings  []UserSetting `gorm:"foreignkey:UserID"`
	Bookmarks []Bookmark    `gorm:"foreignkey:UserID" json:"-"`
}

func (*User) ComparePasswordAndHash

func (u *User) ComparePasswordAndHash(password string) (match bool, err error)

func (*User) CoursesForSemester

func (u *User) CoursesForSemester(year int, term string, context context.Context) []Course

func (*User) GetLoginString

func (u *User) GetLoginString() string

GetLoginString returns the email if it is set, otherwise the lrzID

func (*User) GetPlaybackSpeeds added in v1.0.6

func (u *User) GetPlaybackSpeeds() (speeds PlaybackSpeedSettings)

func (User) GetPreferredGreeting added in v1.0.6

func (u User) GetPreferredGreeting() string

GetPreferredGreeting returns the preferred greeting of the user if set, otherwise Moin

func (User) GetPreferredName added in v1.0.6

func (u User) GetPreferredName() string

GetPreferredName returns the preferred name of the user if set, otherwise the firstName from TUMOnline

func (*User) IsAdminOfCourse

func (u *User) IsAdminOfCourse(course Course) bool

IsAdminOfCourse checks if the user is an admin of the course

func (*User) IsEligibleToWatchCourse

func (u *User) IsEligibleToWatchCourse(course Course) bool

func (User) PreferredNameChangeAllowed added in v1.0.6

func (u User) PreferredNameChangeAllowed() bool

PreferredNameChangeAllowed returns false if the user has set a preferred name within the last 3 months, otherwise true

func (*User) SetPassword

func (u *User) SetPassword(password string) (err error)

type UserSetting added in v1.0.6

type UserSetting struct {
	gorm.Model

	UserID uint            `gorm:"not null"`
	Type   UserSettingType `gorm:"not null"`
	Value  string          `gorm:"not null"` //json encoded setting
}

type UserSettingType added in v1.0.6

type UserSettingType int
const (
	PreferredName UserSettingType = iota + 1
	Greeting
	CustomPlaybackSpeeds
)

type VideoSection added in v1.0.4

type VideoSection struct {
	gorm.Model

	Description  string `gorm:"not null;index:,class:FULLTEXT" json:"description"`
	StartHours   uint   `gorm:"not null" json:"startHours"`
	StartMinutes uint   `gorm:"not null" json:"startMinutes"`
	StartSeconds uint   `gorm:"not null" json:"startSeconds"`

	StreamID uint `gorm:"not null" json:"streamID"`
	FileID   uint `gorm:"not null" json:"fileID"`
}

func (VideoSection) TimestampAsString added in v1.0.4

func (v VideoSection) TimestampAsString() string

type VideoSeekChunk added in v1.1.0

type VideoSeekChunk struct {
	ChunkIndex uint `gorm:"primaryKey;autoIncrement:false" json:"chunkIndex"`
	Hits       uint `gorm:"not null" json:"hits"`
	StreamID   uint `gorm:"primaryKey;autoIncrement:false" json:"streamID"`
}

type Worker

type Worker struct {
	WorkerID string `gorm:"primaryKey"`
	Host     string
	Status   string
	Workload uint // How much the worker has to do. +1 per silence detection job, +2 per converting job, +3 per streaming job
	LastSeen time.Time

	// VM stats:
	CPU    string
	Memory string
	Disk   string
	Uptime string

	Version string
}

func (*Worker) IsAlive

func (w *Worker) IsAlive() bool

Jump to

Keyboard shortcuts

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