Documentation
¶
Index ¶
- Constants
- func CalculateCooldown(delay time.Duration, last time.Time) (time.Duration, bool)
- func CalculateRequestDelay(requestCount int) time.Duration
- func CalculateSubmissionCooldown(t time.Time) time.Duration
- func GenerateHashFromPassword(passwd string) (string, error)
- func GenerateRandomPassword(length int) (string, error)
- func IsGuest(user User) bool
- func IsRobot(user User) bool
- func Metadata(artist, title string) string
- func NickToUsername(nick string) string
- func UsernameToNick(username string) string
- type AnnounceService
- type DJ
- type DJID
- type DatabaseTrack
- type GuestAction
- type GuestService
- type LastPlayedKey
- type Listener
- type ListenerClientID
- type ListenerTrackerService
- type Listeners
- type ManagerService
- type NewsComment
- type NewsCommentID
- type NewsList
- type NewsPost
- type NewsPostID
- type NewsStorage
- type NewsStorageService
- type PendingSong
- type PostPendingID
- type PostPendingSong
- type ProxyMetadataEvent
- type ProxyService
- type ProxySource
- type ProxySourceEvent
- type ProxySourceEventType
- type Queue
- type QueueEntry
- type QueueID
- type QueueService
- type QueueStorage
- type QueueStorageService
- type Relay
- type RelayStorage
- type RelayStorageService
- type RequestStorage
- type RequestStorageService
- type ScheduleDay
- type ScheduleEntry
- type ScheduleID
- type ScheduleStorage
- type ScheduleStorageService
- type SearchOptions
- type SearchResult
- type SearchService
- type Session
- type SessionStorage
- type SessionStorageService
- type SessionToken
- type Song
- type SongHash
- type SongID
- type SongInfo
- type SongStorage
- type SongStorageService
- type SongUpdate
- type SourceID
- type Status
- type StatusStorage
- type StatusStorageService
- type StorageService
- type StorageTx
- type StreamerService
- type SubmissionID
- type SubmissionStats
- type SubmissionStatus
- type SubmissionStorage
- type SubmissionStorageService
- type Theme
- type ThemeName
- type Thread
- type TrackID
- type TrackState
- type TrackStorage
- type TrackStorageService
- type User
- type UserID
- type UserPermission
- type UserPermissions
- type UserStorage
- type UserStorageService
Constants ¶
const ( LimitArtistLength = 500 LimitAlbumLength = 200 LimitTitleLength = 200 LimitReasonLength = 120 )
const ( PermActive = "active" // User is active PermNews = "news" // User has news creation/editing access PermDJ = "dj" // User has access to the icecast proxy PermDev = "dev" // User is a developer PermAdmin = "admin" // User is an administrator PermStaff = "staff" // User is staff, only for display purposes on staff page PermDatabaseDelete = "database_delete" // User can delete from the track database PermDatabaseEdit = "database_edit" // User can edit the track database PermDatabaseView = "database_view" // User can view the track database PermPendingEdit = "pending_edit" // User can edit the pending track queue PermPendingView = "pending_view" // User can view the pending track queue PermQueueEdit = "queue_edit" // User can edit the streamer queue PermRobot = "robot" // User is not human PermScheduleEdit = "schedule_edit" // User can edit the schedule PermListenerView = "listener_view" // User can view the listener list PermListenerKick = "listener_kick" // User can kick listeners PermProxyKick = "proxy_kick" // User can kick streamers" PermTelemetryView = "telemetry_view" // User can view telemetry backend PermGuest = "guest" // User is a guest )
List of permissions, this should be kept in sync with the database version
const LPKeyLast = LastPlayedKey(math.MaxUint32)
Variables ¶
This section is empty.
Functions ¶
func CalculateCooldown ¶
CalculateCooldown sees if the cooldown given has passed since `last` and returns the remaining time if any and a bool indicating if it has passed since then or not. It always returns true if `last` is zero.
func CalculateRequestDelay ¶
CalculateRequestDelay returns the delay between two requests of a song
func GenerateRandomPassword ¶
func Metadata ¶
Metadata returns either "{artist} - {title}" or "{title}" if artist is empty. Both arguments are also trimmed of spaces before doing this
func NickToUsername ¶
func UsernameToNick ¶
Types ¶
type AnnounceService ¶
type DJ ¶
type DJ struct {
ID DJID
Name string
Regex string
Text string
Image string
Visible bool
Priority int
Role string
CSS string
Color string
Theme ThemeName
}
DJ is someone that has access to streaming
type DatabaseTrack ¶
type DatabaseTrack struct {
TrackID TrackID
Artist string
Title string
Album string
FilePath string
Tags string
Acceptor string
LastEditor string
Priority int
Usable bool
NeedReplacement bool
LastRequested time.Time
RequestCount int
}
DatabaseTrack is a song we have the actual audio file for and is available to the automated streamer
func (*DatabaseTrack) HasTrack ¶
func (t *DatabaseTrack) HasTrack() bool
HasTrack returns true if t != nil, can be used as Song.HasTrack to check if a track was allocated for the embedded field
type GuestAction ¶
type GuestAction int
const ( GuestNone GuestAction = iota GuestKill GuestThread )
type GuestService ¶
type GuestService interface {
// Create creates a new user based on the nick given and returns the newly created
// user and passwd if possible, passwd can be empty.
Create(ctx context.Context, nick string) (user *User, passwd string, err error)
// Auth authorizes a guest user to the system, allowing them to do certain actions
Auth(ctx context.Context, nick string) (user *User, err error)
// Deauth removes a guest user from the authorization list
Deauth(ctx context.Context, nick string) error
// Do checks if a guest is allowed to do the GuestAction given and increments any limits if
// applicable to the action
Do(ctx context.Context, nick string, can GuestAction) (ok bool, err error)
// CanDo checks if a guest is allowed to do the GuestAction given
CanDo(ctx context.Context, nick string, can GuestAction) (ok bool, err error)
}
type LastPlayedKey ¶
type LastPlayedKey uint32
type Listener ¶
type Listener struct {
ID ListenerClientID
UserAgent string
IP string
Start time.Time
}
Listener is a listener of the stream
type ListenerClientID ¶
type ListenerClientID uint64
ListenerClientID is an identifier unique to each listener
func ParseListenerClientID ¶
func ParseListenerClientID(s string) (ListenerClientID, error)
ParseListenerClientID parses a string as a ListenerClientID, input is expected to be like the output of ListenerClientID.String
func (ListenerClientID) String ¶
func (c ListenerClientID) String() string
String returns the ListenerClientID as a string
type ListenerTrackerService ¶
type ManagerService ¶
type ManagerService interface {
UpdateFromStorage(context.Context) error
CurrentUser(context.Context) (eventstream.Stream[*User], error)
UpdateUser(context.Context, *User) error
CurrentSong(context.Context) (eventstream.Stream[*SongUpdate], error)
UpdateSong(context.Context, *SongUpdate) error
CurrentThread(context.Context) (eventstream.Stream[Thread], error)
UpdateThread(context.Context, Thread) error
CurrentListeners(context.Context) (eventstream.Stream[Listeners], error)
UpdateListeners(context.Context, Listeners) error
CurrentStatus(context.Context) (eventstream.Stream[Status], error)
}
type NewsComment ¶
type NewsComment struct {
ID NewsCommentID
PostID NewsPostID
Body string
Identifier string
// Optional, only filled if an account-holder comments
UserID *UserID
User *User
DeletedAt *time.Time
CreatedAt time.Time
UpdatedAt *time.Time
}
NewsComment is a single comment under a news post on the website
type NewsCommentID ¶
type NewsCommentID uint32
NewsCommentID is an identifier for a news comment
func ParseNewsCommentID ¶
func ParseNewsCommentID(s string) (NewsCommentID, error)
func (NewsCommentID) String ¶
func (id NewsCommentID) String() string
type NewsPost ¶
type NewsPost struct {
ID NewsPostID
Title string
Header string
Body string
User User
DeletedAt *time.Time
CreatedAt time.Time
UpdatedAt *time.Time
Private bool
}
NewsPost is a single news post created on the website
func (NewsPost) HasRequired ¶
HasRequired tells if you all required fields in a news post are filled, returns the field name that is missing and a boolean
type NewsPostID ¶
type NewsPostID uint32
NewsPostID is an identifier for a news post
func ParseNewsPostID ¶
func ParseNewsPostID(s string) (NewsPostID, error)
func (NewsPostID) String ¶
func (id NewsPostID) String() string
type NewsStorage ¶
type NewsStorage interface {
// Get returns the news post associated with the id given
Get(NewsPostID) (*NewsPost, error)
// Create creates a new news post
//
// Required fields to create a post are (title, header, body, user)
Create(NewsPost) (NewsPostID, error)
// Update updates the news post entry
Update(NewsPost) error
// Delete deletes a news post
Delete(NewsPostID) error
// List returns a list of news post starting at offset and returning up to
// limit amount of posts, chronologically sorted by creation date
List(limit int64, offset int64) (NewsList, error)
// ListPublic returns the same thing as List but with deleted and private
// posts filtered out
ListPublic(limit int64, offset int64) (NewsList, error)
// AddComment adds a comment to a news post
AddComment(NewsComment) (NewsCommentID, error)
// DeleteComment deletes a comment from a news post
DeleteComment(NewsCommentID) error
// Comments returns all comments associated with the news post given
Comments(NewsPostID) ([]NewsComment, error)
// CommentsPublic returns all comments that were not deleted
CommentsPublic(NewsPostID) ([]NewsComment, error)
}
NewsStorage stores website news and its comments
type NewsStorageService ¶
type NewsStorageService interface {
News(context.Context) NewsStorage
NewsTx(context.Context, StorageTx) (NewsStorage, StorageTx, error)
}
NewsStorageService is a service able to supply a NewsStorage
type PendingSong ¶
type PendingSong struct {
ID SubmissionID
// Status of the song (accepted/declined/pending)
Status SubmissionStatus
// Artist of the song
Artist string
// Title of the song
Title string
// Album of the song
Album string
// Tags of the song
Tags string
// FilePath on disk
FilePath string
// Comment given by the uploader
Comment string
// Filename is the original filename from the uploader
Filename string
// UserIdentifier is the unique identifier for the uploader
UserIdentifier string
// SubmittedAt is the time of submission
SubmittedAt time.Time
// ReviewedAt tells you when the song was reviewed
ReviewedAt time.Time
// Duplicate indicates if this might be a duplicate
Duplicate bool
// ReplacementID is the TrackID that this upload will replace
ReplacementID *TrackID
// Bitrate of the file
Bitrate uint
// Length of the song
Length time.Duration
// Format of the song
Format string
// EncodingMode is the encoding mode used for the file
EncodingMode string
// Decline fields
Reason string
// Accepted fields
GoodUpload bool
AcceptedSong *Song
}
PendingSong is a song currently awaiting approval in the pending queue
func (PendingSong) Metadata ¶
func (p PendingSong) Metadata() string
type PostPendingID ¶
type PostPendingID int32
func ParsePostPendingID ¶
func ParsePostPendingID(s string) (PostPendingID, error)
func (PostPendingID) String ¶
func (id PostPendingID) String() string
type PostPendingSong ¶
type PostPendingSong struct {
ID PostPendingID
AcceptedSong *TrackID
Metadata string
UserIdentifier string
ReviewedAt time.Time
DeclineReason *string
AcceptStatus SubmissionStatus
}
type ProxyMetadataEvent ¶
type ProxyService ¶
type ProxyService interface {
MetadataStream(context.Context) (eventstream.Stream[ProxyMetadataEvent], error)
SourceStream(context.Context) (eventstream.Stream[ProxySourceEvent], error)
StatusStream(context.Context, UserID) (eventstream.Stream[[]ProxySource], error)
KickSource(context.Context, SourceID) error
ListSources(context.Context) ([]ProxySource, error)
}
type ProxySource ¶
type ProxySourceEvent ¶
type ProxySourceEvent struct {
ID SourceID
MountName string
User User
Event ProxySourceEventType
}
type ProxySourceEventType ¶
type ProxySourceEventType int
const ( SourceDisconnect ProxySourceEventType = iota SourceConnect SourceLive )
type Queue ¶
type Queue []QueueEntry
func (Queue) Limit ¶
Limit limits the queue size to the maxSize given or the whole queue if maxSize < len(queue)
func (Queue) RequestAmount ¶
RequestAmount returns the amount of QueueEntries that have IsUserRequest set to true
type QueueEntry ¶
type QueueEntry struct {
// QueueID is a unique identifier for this queue entry
QueueID QueueID
// Song that is queued
Song
// IsUserRequest should be true if this song was added to the queue
// by a third-party user
IsUserRequest bool
// UserIdentifier should be a way to identify the user that requested the song
UserIdentifier string
// ExpectedStartTime is the expected time this song will be played on stream
ExpectedStartTime time.Time
}
QueueEntry is a Song used in the QueueService
func (QueueEntry) Copy ¶
func (qe QueueEntry) Copy() QueueEntry
func (*QueueEntry) EqualTo ¶
func (qe *QueueEntry) EqualTo(qe2 QueueEntry) bool
func (QueueEntry) String ¶
func (qe QueueEntry) String() string
type QueueService ¶
type QueueService interface {
// AddRequest requests the given song to be added to the queue, the string given
// is an identifier of the user that requested it
AddRequest(context.Context, Song, string) error
// ReserveNext returns the next yet-to-be-reserved entry from the queue
ReserveNext(context.Context) (*QueueEntry, error)
// ResetReserved resets the reserved status of all entries returned by ReserveNext
// but not yet removed by Remove
ResetReserved(context.Context) error
// Remove removes the first occurrence of the given entry from the queue
Remove(context.Context, QueueID) (bool, error)
// Entries returns all entries in the queue
Entries(context.Context) (Queue, error)
}
type QueueStorage ¶
type QueueStorage interface {
// Store stores the queue with the name given
Store(name string, queue []QueueEntry) error
// Load returns the queue associated with the name given
Load(name string) ([]QueueEntry, error)
}
QueueStorage stores a queue
type QueueStorageService ¶
type QueueStorageService interface {
Queue(context.Context) QueueStorage
QueueTx(context.Context, StorageTx) (QueueStorage, StorageTx, error)
}
QueueStorageService is a service able to supply a QueueStorage
type Relay ¶
type Relay struct {
Name, Status, Stream, Err string
Online, Disabled, Noredir bool
Listeners, Max int
}
Relay is a stream relay for use by the load balancer.
type RelayStorage ¶
RelayStorage deals with the relays table.
type RelayStorageService ¶
type RelayStorageService interface {
Relay(context.Context) RelayStorage
RelayTx(context.Context, StorageTx) (RelayStorage, StorageTx, error)
}
RelayStorageService is a service able to supply a RelayStorage
type RequestStorage ¶
type RequestStorage interface {
// LastRequest returns the time of when the identifier given last requested
// a song from the streamer
LastRequest(identifier string) (time.Time, error)
// UpdateLastRequest updates the LastRequest time to the current time for the
// identifier given
UpdateLastRequest(identifier string) error
}
RequestStorage stores things related to automated streamer song requests
type RequestStorageService ¶
type RequestStorageService interface {
Request(context.Context) RequestStorage
RequestTx(context.Context, StorageTx) (RequestStorage, StorageTx, error)
}
RequestStorageService is a service able to supply a RequestStorage
type ScheduleDay ¶
type ScheduleDay uint8
const ( Monday ScheduleDay = iota Tuesday Wednesday Thursday Friday Saturday Sunday UnknownDay ScheduleDay = 255 )
func ParseScheduleDay ¶
func ParseScheduleDay(s string) ScheduleDay
func (ScheduleDay) String ¶
func (day ScheduleDay) String() string
type ScheduleEntry ¶
type ScheduleEntry struct {
ID ScheduleID
// Weekday is the day this entry is for
Weekday ScheduleDay
// Text is the actual body of the entry
Text string
// Owner is who "owns" this day for streaming rights
Owner *User
// UpdatedAt is when this was updated
UpdatedAt time.Time
// UpdatedBy is who updated this
UpdatedBy User
// Notification indicates if we should notify users of this entry
Notification bool
}
type ScheduleID ¶
type ScheduleID uint32
type ScheduleStorage ¶
type ScheduleStorage interface {
// Latest returns the latest version of the schedule, one entry for
// each day in order from Monday to Sunday. entry is nil if there is
// no schedule for that day
Latest() ([]*ScheduleEntry, error)
// Update updates the schedule with the entry given
Update(ScheduleEntry) error
// History returns the previous versions of ScheduleEntry
History(day ScheduleDay, limit, offset int64) ([]ScheduleEntry, error)
}
type ScheduleStorageService ¶
type ScheduleStorageService interface {
Schedule(context.Context) ScheduleStorage
ScheduleTx(context.Context, StorageTx) (ScheduleStorage, StorageTx, error)
}
type SearchOptions ¶
type SearchResult ¶
type SearchService ¶
type Session ¶
type Session struct {
Token SessionToken
Expiry time.Time
Data []byte
}
Session is a website user session
type SessionStorage ¶
type SessionStorage interface {
Delete(SessionToken) error
Get(SessionToken) (Session, error)
Save(Session) error
}
SessionStorage stores Session's by a SessionToken
type SessionStorageService ¶
type SessionStorageService interface {
Sessions(context.Context) SessionStorage
SessionsTx(context.Context, StorageTx) (SessionStorage, StorageTx, error)
}
SessionStorageService is a service that supplies a SessionStorage
type SessionToken ¶
type SessionToken string
SessionToken is the token associated with a singular session
type Song ¶
type Song struct {
ID SongID
// Hash is a sha1 of the contents of Metadata
Hash SongHash
// HashLink is the same as Hash but points to another song that we share some data with
HashLink SongHash
// Metadata is simple metadata for this song in the format 'artist - title'
Metadata string
// Length is the length of the song
Length time.Duration
// LastPlayed is the last time this song played on stream
LastPlayed time.Time
// LastPlayedBy is the user that last played this song, can be nil
LastPlayedBy *User
// DatabaseTrack is only available if the song is in our streamer database
*DatabaseTrack
// SyncTime is the time this Song was returned by the database layer
SyncTime time.Time
}
Song is a song we've seen played on the stream
func (*Song) Hydrate ¶
func (s *Song) Hydrate()
Hydrate tries to fill Song with data from other fields, mostly useful for if we have a DatabaseTrack but want to create the Song fields
func (*Song) RequestDelay ¶
RequestDelay returns the period between requests for this song, this value is based on the RequestCount of the song or 0 if the song is nil
func (*Song) Requestable ¶
Requestable returns whether this song can be requested by a user
func (*Song) UntilRequestable ¶
UntilRequestable returns the time until this song can be requested again, returns 0 if song.Requestable() == true
type SongHash ¶
SongHash is a sha1 hash
func NewSongHash ¶
NewSongHash generates a new SongHash for the metadata passed in
func ParseSongHash ¶
ParseSongHash reverts SongHash.String
func (SongHash) MarshalJSON ¶
MarshalJSON implements encoding/json.Marshaler
func (*SongHash) UnmarshalJSON ¶
UnmarshalJSON implements encoding/json.Unmarshaler
type SongStorage ¶
type SongStorage interface {
// Create creates a new song with the metadata given
Create(Song) (*Song, error)
// FromMetadata returns the song associated with the metadata given
FromMetadata(metadata string) (*Song, error)
// FromHash returns the song associated with the SongHash given
FromHash(SongHash) (*Song, error)
// LastPlayed returns songs that have recently played, up to amount given after
// applying the offset
LastPlayed(key LastPlayedKey, amountPerPage int) ([]Song, error)
// LastPlayedPagination looks up keys for adjacent pages of key
LastPlayedPagination(key LastPlayedKey, amountPerPage, pageCount int) (prev, next []LastPlayedKey, err error)
// LastPlayedCount returns the amount of plays recorded
LastPlayedCount() (int64, error)
// PlayedCount returns the amount of times the song has been played on stream,
// returns 0 if the song doesn't exist
PlayedCount(Song) (int64, error)
// AddPlay adds a play to the song. streamer is the dj that played the song.
// If present, ldiff is the difference in amount of listeners between
// song-start and song-end.
AddPlay(song Song, streamer User, ldiff *Listeners) error
// FavoriteCount returns the amount of users that have added this song to
// their favorite list, returns 0 if the song doesn't exist
FavoriteCount(Song) (int64, error)
// Favorites returns all users that have this song on their favorite list
Favorites(Song) ([]string, error)
// FavoritesOf returns all songs that are on a users favorite list
FavoritesOf(nick string, limit, offset int64) ([]Song, int64, error)
// FavoritesOfDatabase returns all songs that are on a users favorite list
// and also have a track database
FavoritesOfDatabase(nick string) ([]Song, error)
// AddFavorite adds the given song to nicks favorite list
AddFavorite(song Song, nick string) (bool, error)
// RemoveFavorite removes the given song from nicks favorite list
RemoveFavorite(song Song, nick string) (bool, error)
// UpdateLength updates the stored length of the song
UpdateLength(Song, time.Duration) error
// UpdateHashLink updates the HashLink of the song
UpdateHashLink(old SongHash, new SongHash) error
}
SongStorage stores information about songs
A song can be anything that plays on stream, unlike a track which is a specific kind of song that we have an audio file for and can be played by the automated streamer
type SongStorageService ¶
type SongStorageService interface {
Song(context.Context) SongStorage
SongTx(context.Context, StorageTx) (SongStorage, StorageTx, error)
}
SongStorageService is a service able to supply a SongStorage
type SongUpdate ¶
type SourceID ¶
func ParseSourceID ¶
type Status ¶
type Status struct {
// StreamUser is the user that is currently streaming, will be nil
// if no one is connected on the master mountpoint (even short drops)
StreamUser *User
// User is the user that is currently or was the last to broadcast
// on the stream
User User
// Song is the song that is currently playing on the stream
Song Song
// SongInfo is extra information about the song that is currently playing
SongInfo SongInfo
// StreamerName is the name given to us by the user that is streaming
StreamerName string
// Listeners is the current amount of stream listeners
Listeners Listeners
// Thread is an URL to a third-party platform related to the current stream
Thread string
}
type StatusStorage ¶
type StatusStorage interface {
// Store stores the Status given
Store(Status) error
// Load returns the previously stored Status
Load() (*Status, error)
}
StatusStorage stores a Status structure
type StatusStorageService ¶
type StatusStorageService interface {
Status(context.Context) StatusStorage
}
StatusStorageService is a service able to supply a StatusStorage
type StorageService ¶
type StorageService interface {
SessionStorageService
RelayStorageService
QueueStorageService
SongStorageService
TrackStorageService
RequestStorageService
UserStorageService
StatusStorageService
SubmissionStorageService
NewsStorageService
ScheduleStorageService
// Close closes the storage service and cleans up any resources
Close() error
}
StorageService is an interface containing all *StorageService interfaces
type StreamerService ¶
type SubmissionID ¶
type SubmissionID uint32
SubmissionID is the ID of a pending song
func ParseSubmissionID ¶
func ParseSubmissionID(s string) (SubmissionID, error)
func (SubmissionID) String ¶
func (id SubmissionID) String() string
type SubmissionStats ¶
type SubmissionStats struct {
// Amount of submissions in the pending queue
CurrentPending int `db:"current_pending"`
// Information about accepted songs
AcceptedTotal int `db:"accepted_total"`
AcceptedLastTwoWeeks int `db:"accepted_last_two_weeks"`
AcceptedYou int `db:"accepted_you"`
RecentAccepts []PostPendingSong
// Information about declined songs
DeclinedTotal int `db:"declined_total"`
DeclinedLastTwoWeeks int `db:"declined_last_two_weeks"`
DeclinedYou int `db:"declined_you"`
RecentDeclines []PostPendingSong
// Information about (You)
LastSubmissionTime time.Time `db:"last_submission_time"`
}
type SubmissionStatus ¶
type SubmissionStatus int
SubmissionStatus is the status of a submitted song
const ( SubmissionDeclined SubmissionStatus = iota SubmissionAccepted SubmissionReplacement SubmissionAwaitingReview )
const SubmissionInvalid SubmissionStatus = -1
Possible status for song submissions
type SubmissionStorage ¶
type SubmissionStorage interface {
// LastSubmissionTime returns the last known time of when the identifier
// was used to upload a submission
LastSubmissionTime(identifier string) (time.Time, error)
// UpdateSubmissionTime updates the last submission time to the current time
// for the identifier given
UpdateSubmissionTime(identifier string) error
// SubmissionStats returns the submission stats for the identifier given.
SubmissionStats(identifier string) (SubmissionStats, error)
// All returns all submissions
All() ([]PendingSong, error)
// InsertSubmission inserts a new pending song into the database
InsertSubmission(PendingSong) error
// GetSubmission returns a pending song by ID
GetSubmission(SubmissionID) (*PendingSong, error)
// RemoveSubmission removes a pending song by ID
RemoveSubmission(SubmissionID) error
// InsertPostPending inserts post-pending data
InsertPostPending(PendingSong) error
}
SubmissionStorage stores stuff related to the reviewing of submissions and associated information
type SubmissionStorageService ¶
type SubmissionStorageService interface {
Submissions(context.Context) SubmissionStorage
SubmissionsTx(context.Context, StorageTx) (SubmissionStorage, StorageTx, error)
}
SubmissionStorageService is a service able to supply a SubmissionStorage
type Theme ¶
type Theme struct {
Name ThemeName `toml:"-"`
DisplayName string `toml:"DisplayName"`
Description string `toml:"Description"`
Author string `toml:"Author"`
}
Theme is a website theme
type TrackState ¶
type TrackState int
TrackState is the state of a Track in storage
const ( TrackStateUnverified TrackState = iota TrackStatePlayable )
type TrackStorage ¶
type TrackStorage interface {
// Get returns a single track with the TrackID given
Get(TrackID) (*Song, error)
// All returns all tracks in storage
All() ([]Song, error)
// AllRaw returns all tracks in storage, but without making sure all fields
// are filled. This returns them as-is straight from storage
AllRaw() ([]Song, error)
// Delete removes a track from storage
Delete(TrackID) error
// Unusable returns all tracks that are deemed unusable by the streamer
Unusable() ([]Song, error)
// NeedReplacement returns the song that need a replacement
NeedReplacement() ([]Song, error)
// Insert inserts a new track, errors if ID or TrackID is set
Insert(song Song) (TrackID, error)
// Random returns limit amount of usable tracks
Random(limit int) ([]Song, error)
// RandomFavorite returns limit amount of tracks that are on the nicks favorite list
RandomFavoriteOf(nick string, limit int) ([]Song, error)
// FilterSongsFavoriteOf returns the songs given that are favorite'd by the nick given, it
// is allowed to mutate the slice given as argument.
FilterSongsFavoriteOf(nick string, songs []Song) ([]Song, error)
// UpdateMetadata updates track metadata only (artist/title/album/tags/filepath/needreplacement)
UpdateMetadata(song Song) error
// UpdateUsable sets usable to the state given
UpdateUsable(song Song, state TrackState) error
// UpdateRequestInfo is called after a track has been requested, this should do any
// necessary book-keeping related to that
UpdateRequestInfo(TrackID) error
// UpdateLastPlayed sets the last time the track was played to the current time
UpdateLastPlayed(TrackID) error
// UpdateLastRequested sets the last time the track was requested to the current time
UpdateLastRequested(TrackID) error
// BeforeLastRequested returns all tracks that have their LastRequested before the
// time given
BeforeLastRequested(before time.Time) ([]Song, error)
// DecrementRequestCount decrements the RequestCount for all tracks that have
// their LastRequested before the time given
DecrementRequestCount(before time.Time) error
// QueueCandidates returns tracks that are candidates to be queue'd by the
// default queue implementation
QueueCandidates() ([]TrackID, error)
}
TrackStorage stores information about tracks
A track is a song that we have the audio file for and can thus be played by the automated streaming system
type TrackStorageService ¶
type TrackStorageService interface {
Track(context.Context) TrackStorage
TrackTx(context.Context, StorageTx) (TrackStorage, StorageTx, error)
}
TrackStorageService is a service able to supply a TrackStorage
type User ¶
type User struct {
ID UserID
Username string
Password string `json:"-"`
Email string
RememberToken string `json:"-"`
IP string
UpdatedAt *time.Time
DeletedAt *time.Time
CreatedAt time.Time
DJ DJ
UserPermissions UserPermissions
}
User is an user account in the database
func (User) ComparePassword ¶
type UserID ¶
type UserID uint32
UserID is an identifier corresponding to an user
func ParseUserID ¶
type UserPermission ¶
type UserPermission string
UserPermission is a permission for user authorization
func AllUserPermissions ¶
func AllUserPermissions() []UserPermission
func (UserPermission) String ¶
func (u UserPermission) String() string
type UserPermissions ¶
type UserPermissions map[UserPermission]struct{}
func NewUserPermissions ¶
func NewUserPermissions(perms ...UserPermission) UserPermissions
func (UserPermissions) Has ¶
func (up UserPermissions) Has(perm UserPermission) bool
Has returns true if the permissions in UserPermission allow access to the permission given
func (UserPermissions) HasEdit ¶
func (up UserPermissions) HasEdit(perm UserPermission) bool
HasEdit returns true if the UserPermissions is allowed to edit the given permission
func (UserPermissions) HasExplicit ¶
func (up UserPermissions) HasExplicit(perm UserPermission) bool
HasExplicit returns true if the permission given is explicitly in the UserPermissions
func (*UserPermissions) Scan ¶
func (upp *UserPermissions) Scan(src any) error
Scan implements sql.Scanner
Done in a way that it expects all permissions to be a single string or []byte separated by a comma
type UserStorage ¶
type UserStorage interface {
// All returns all users
All() ([]User, error)
// Create creates a user
Create(User) (UserID, error)
// CreateDJ creates a DJ for the user given
CreateDJ(User, DJ) (DJID, error)
// Get returns the user matching the name given
Get(name string) (*User, error)
// GetByID returns the user associated with the UserID
GetByID(UserID) (*User, error)
// GetByDJID returns the user associated with the DJID
GetByDJID(DJID) (*User, error)
// Update updates the given user
Update(User) (User, error)
// LookupName matches the name given fuzzily to a user
LookupName(name string) (*User, error)
// ByNick returns an user that is associated with the nick given
ByNick(nick string) (*User, error)
// Permissions returns all available permissions
Permissions() ([]UserPermission, error)
// RecordListeners records a history of listener count
RecordListeners(Listeners, User) error
}
UserStorage stores things related to users with actual accounts on the website
type UserStorageService ¶
type UserStorageService interface {
User(context.Context) UserStorage
UserTx(context.Context, StorageTx) (UserStorage, StorageTx, error)
}
UserStorageService is a service able to supply a UserStorage