67 lines
1.5 KiB
Go

package entity
import (
"regexp"
"strings"
)
// Event represents the type of event for the channel.
type Event = string
const (
EventUpdate Event = "update"
EventLog Event = "log"
)
// ChannelConfig represents the configuration for a channel.
type ChannelConfig struct {
IsPaused bool `json:"is_paused"`
Username string `json:"username"`
Framerate int `json:"framerate"`
Resolution int `json:"resolution"`
Pattern string `json:"pattern"`
MaxDuration int `json:"max_duration"`
MaxFilesize int `json:"max_filesize"`
CreatedAt int64 `json:"created_at"`
}
func (c *ChannelConfig) Sanitize() {
c.Username = regexp.MustCompile(`[^a-zA-Z0-9_-]`).ReplaceAllString(c.Username, "")
c.Username = strings.TrimSpace(c.Username)
}
// ChannelInfo represents the information about a channel,
// mostly used for the template rendering.
type ChannelInfo struct {
IsOnline bool
IsPaused bool
Username string
Duration string
Filesize string
Filename string
StreamedAt string
MaxDuration string
MaxFilesize string
CreatedAt int64
Logs []string
GlobalConfig *Config // for nested template to access $.Config
}
// Config holds the configuration for the application.
type Config struct {
Version string
Username string
AdminUsername string
AdminPassword string
Framerate int
Resolution int
Pattern string
MaxDuration int
MaxFilesize int
Port string
Interval int
Cookies string
UserAgent string
Domain string
}