Documentation
¶
Index ¶
- Constants
- Variables
- func AddMedia(tx *db.Tx, entry media.MediaListEntry) (id int, hasErr bool)
- func AddPlaylistItems(tx *db.Tx, playlist int, mediaIds []int, beginOrder, deltaOrder int) (ids []int, hasErr bool)
- func AddPlaylistManager(tx *db.Tx, playlist int, username string) (hasErr bool)
- func AddToPlaylist(tx *db.Tx, playlist int, canonInfo media.MediaCanonicalizeInfo, ...) (hasErr bool)
- func CheckPlaylistExists(tx *db.Tx, id int) (hasRow bool, hasErr bool)
- func CheckPlaylistItemExists(tx *db.Tx, playlist, id int) (hasRow bool, hasErr bool)
- func CheckUserExists(tx *db.Tx, username string) (hasRow bool, hasErr bool)
- func ConfirmMail(tx *db.Tx, identifier, username string) (hasErr bool)
- func CreatePlaylist(tx *db.Tx, username string, name string) (id int, hasError bool)
- func DeletePlaylist(tx *db.Tx, username string, id int) (hasErr bool)
- func DeletePlaylistItem(tx *db.Tx, playlist int, id int) (hasErr bool)
- func DeletePlaylistManager(tx *db.Tx, playlist int, username string) (hasErr bool)
- func EnumeratePlaylistManagers(tx *db.Tx, playlist int) (managers []string, hasErr bool)
- func GetCurrentMedia(tx *db.Tx, playlist int) (itemId sql.NullInt32, hasErr bool)
- func GetMediaId(tx *db.Tx, url string) (id int, hasRow, hasErr bool)
- func GetMediaSimpleInfo(tx *db.Tx, url string) (id int, title, artist string, hasRow, hasErr bool)
- func GetNextPlaylistItem(tx *db.Tx, playlist, prevOrder int) (id int, order int, hasRow, hasErr bool)
- func GetPlaylistItemOrder(tx *db.Tx, id int) (order int, hasErr bool)
- func GetPlaylistOwner(tx *db.Tx, playlist int) (owner string, hasErr bool)
- func IsPlaylistManager(tx *db.Tx, username string, playlist int) (isManager, hasError bool)
- func IsPlaylistOwner(tx *db.Tx, username string, playlist int) (isOwner, hasErr bool)
- func LocalRebalance(tx *db.Tx, playlist int, startOrder int, endOrder int, beforeItem int, ...) (begin int, delta int, hasErr bool)
- func LogIn(tx *db.Tx, username, password string) (signedToken string, timeout time.Duration, hasErr bool)
- func MoveItems(tx *db.Tx, playlist int, items []int, dir MoveDirection) (numAffected int, hasErr bool)
- func NewWebSocketErrorHandler(title string, wsId string) errs.ErrorHandler
- func NotifyMediaChanged(tx *db.Tx, playlist int, socketId string) (callback func(), hasErr bool)
- func PlaylistUpdateCurrent(tx *db.Tx, handler errs.ErrorHandler, playlist int, sign, sortOrder string) (callback func(), hasErr bool)
- func Register(tx *db.Tx, email *mail.Address, username, password string) (hasErr bool)
- func RenamePlaylist(tx *db.Tx, username string, id int, name string) (hasErr bool)
- func ResetPassword(tx *db.Tx, identifier, email, password string) (hasErr bool)
- func ResetPasswordRequestValid(tx *db.Tx, identifier, email string) (hasErr bool)
- func SendNextRequest(tx *db.Tx, handler errs.ErrorHandler, playlist int, username string) (callback func(), hasErr bool)
- func SendRecoveryEmail(tx *db.Tx, email *mail.Address) (hasErr bool)
- func SetCurrentMedia(tx *db.Tx, playlist int, itemId sql.NullInt32) (hasErr bool)
- func SetMediaAltMetadata(tx *db.Tx, title, artist string, playlist, media int) (hasErr bool)
- func WebSocketEvent(socketId, event string)
- func WebSocketMediaChange(playlist int, socketId string, payload MediaChangedPayload)
- func WebSocketPlaylistEvent(playlist int, event WebSocketEventType)
- func WebSocketSwap(socketId string, html template.HTML)
- func WebSocketToast(socketId string, kind html.ToastKind, title template.HTML, ...) error
- type MediaChangedPayload
- type MoveDirection
- type MoveItem
- type Pagination
- func EnumeratePlaylistItems(tx *db.Tx, playlist int, pageNum int) (page Pagination[QueuePlaylistItem], hasError bool)
- func NewPagination[T any](offset int, items []T) Pagination[T]
- func SearchPlaylists(tx *db.Tx, username string, query string, filter PlaylistFilter, offset int) (page Pagination[QueriedPlaylist], hasError bool)
- type PlaylistAddPosition
- type PlaylistFilter
- type PlaylistState
- type QueriedPlaylist
- type QueuePlaylistItem
- type WebSocketConnection
- type WebSocketEventType
- type WebSocketManager
- func (manager *WebSocketManager) Add(conn *websocket.Conn, playlist int, username string) string
- func (manager *WebSocketManager) BroadcastPlaylist(id int, msg WebSocketMsg)
- func (manager *WebSocketManager) Remove(playlist int, username string, id string)
- func (manager *WebSocketManager) SendId(id string, msg WebSocketMsg)
- type WebSocketMsg
- type WebSocketMsgType
Constants ¶
View Source
const ( Handshake WebSocketMsgType = "handshake" Swap WebSocketMsgType = "swap" Event WebSocketMsgType = "event" MediaChanged WebSocketMsgType = "media-change" ManagersChanged WebSocketEventType = "refresh-managers" PlaylistChanged WebSocketEventType = "refresh-playlist" )
View Source
const DefaultPagingLimit = 10
View Source
const PlaylistAddOrderGap = 1 << 10
Variables ¶
View Source
var AlreadyPlaylistManagerError = errors.New("This user is already a playlist manager.")
View Source
var AlreadyPlaylistOwnerError = errors.New("This user (you) is already the playlist owner.")
View Source
var GenericError = errors.New("Internal server error.")
View Source
var NoCurrentMediaError = errors.New("No current media.")
View Source
var UserNotFoundError = errors.New("User not found.")
Functions ¶
func AddPlaylistItems ¶
func AddPlaylistManager ¶
func AddToPlaylist ¶
func AddToPlaylist(tx *db.Tx, playlist int, canonInfo media.MediaCanonicalizeInfo, pos PlaylistAddPosition) (hasErr bool)
func CheckPlaylistItemExists ¶
func CreatePlaylist ¶
func DeletePlaylistManager ¶
func EnumeratePlaylistManagers ¶
excluding owner
func GetCurrentMedia ¶
func GetMediaSimpleInfo ¶
func GetNextPlaylistItem ¶
func IsPlaylistManager ¶
func IsPlaylistOwner ¶
func LocalRebalance ¶
func NewWebSocketErrorHandler ¶
func NewWebSocketErrorHandler(title string, wsId string) errs.ErrorHandler
func NotifyMediaChanged ¶
func PlaylistUpdateCurrent ¶
func RenamePlaylist ¶
func ResetPassword ¶
func SendNextRequest ¶
func SetCurrentMedia ¶
func SetMediaAltMetadata ¶
func WebSocketEvent ¶
func WebSocketEvent(socketId, event string)
func WebSocketMediaChange ¶
func WebSocketMediaChange(playlist int, socketId string, payload MediaChangedPayload)
func WebSocketPlaylistEvent ¶
func WebSocketPlaylistEvent(playlist int, event WebSocketEventType)
func WebSocketSwap ¶
Types ¶
type MediaChangedPayload ¶
type MoveDirection ¶
type MoveDirection int
const ( MoveUp MoveDirection = 1 MoveDown MoveDirection = -1 )
type Pagination ¶
type Pagination[T any] struct { Items []T NextOffset int PrevOffset int NextPage int PrevPage int Page int }
func EnumeratePlaylistItems ¶
func EnumeratePlaylistItems(tx *db.Tx, playlist int, pageNum int) (page Pagination[QueuePlaylistItem], hasError bool)
func NewPagination ¶
func NewPagination[T any](offset int, items []T) Pagination[T]
func SearchPlaylists ¶
func SearchPlaylists(tx *db.Tx, username string, query string, filter PlaylistFilter, offset int) (page Pagination[QueriedPlaylist], hasError bool)
type PlaylistAddPosition ¶
type PlaylistAddPosition string
const ( AddToStart PlaylistAddPosition = "add-to-start" AddToEnd PlaylistAddPosition = "add-to-end" QueueNext PlaylistAddPosition = "queue-next" )
func ParsePlaylistAddPosition ¶
func ParsePlaylistAddPosition(pos string) (PlaylistAddPosition, error)
type PlaylistFilter ¶
type PlaylistFilter string
const ( All PlaylistFilter = "all" Owned PlaylistFilter = "owned" Managed PlaylistFilter = "managed" )
func ParsePlaylistFilter ¶
func ParsePlaylistFilter(filter string) (PlaylistFilter, error)
type PlaylistState ¶
type PlaylistState struct {
// contains filtered or unexported fields
}
func (*PlaylistState) Broadcast ¶
func (p *PlaylistState) Broadcast(msg WebSocketMsg)
func (*PlaylistState) NumManagerWatching ¶
func (p *PlaylistState) NumManagerWatching() int
func (*PlaylistState) Remove ¶
func (p *PlaylistState) Remove(username, id string) bool
type QueriedPlaylist ¶
type QueuePlaylistItem ¶
type WebSocketConnection ¶
type WebSocketEventType ¶
type WebSocketEventType string
type WebSocketManager ¶
type WebSocketManager struct {
// contains filtered or unexported fields
}
func GetManager ¶
func GetManager() *WebSocketManager
func (*WebSocketManager) BroadcastPlaylist ¶
func (manager *WebSocketManager) BroadcastPlaylist(id int, msg WebSocketMsg)
func (*WebSocketManager) Remove ¶
func (manager *WebSocketManager) Remove(playlist int, username string, id string)
func (*WebSocketManager) SendId ¶
func (manager *WebSocketManager) SendId(id string, msg WebSocketMsg)
type WebSocketMsg ¶
type WebSocketMsg struct { Type WebSocketMsgType `json:"type"` Payload interface{} `json:"payload"` }
type WebSocketMsgType ¶
type WebSocketMsgType string
Click to show internal directories.
Click to hide internal directories.