controller

package
v0.0.0-...-56a5168 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_MIN_MS_FILTER = 30000
	DEFAULT_LIMIT         = 50
)

Variables

View Source
var (
	SearchMissingError, _ = json.MarshalIndent(requests.ErrorResponse{
		Error: "No search term present",
	}, "", " ")
)
View Source
var (
	SongIDMissingError, _ = json.MarshalIndent(requests.ErrorResponse{
		Error: "No song specified",
	}, "", " ")
)

Functions

This section is empty.

Types

type AddMemberRequest

type AddMemberRequest struct {
	Username    string `json:"username"`
	IsModerator bool   `json:"is_moderator"`
}

type AlbumCount

type AlbumCount struct {
	Name     string  `json:"name"`
	URI      string  `json:"uri"`
	ID       string  `json:"id"`
	ImageURL *string `json:"image_url"`
	Count    int     `json:"count"`
}

type AlbumStatsResponse

type AlbumStatsResponse struct {
	Album      *spotify.FullAlbum      `json:"album"`
	Streams    []*Stream               `json:"streams"`
	Tracks     map[string]db.TrackData `json:"tracks"`
	TrackRanks []*history.TrackStreams `json:"track_ranks"`
}

type ArtistStatsResponse

type ArtistStatsResponse struct {
	Artist     *spotify.FullArtist     `json:"artist"`
	Streams    []*Stream               `json:"streams"`
	Tracks     map[string]db.TrackData `json:"tracks"`
	TrackRanks []*history.TrackStreams `json:"track_ranks"`
}

type CompareAlbumsResp

type CompareAlbumsResp struct {
	StreamsByURI  map[string]map[uuid.UUID]int64        `json:"streams_by_uri"`
	RanksByURI    map[string]map[uuid.UUID]int64        `json:"ranks_by_uri"`
	AlbumData     map[string]spotify.FullAlbum          `json:"album_data"`
	FriendData    map[uuid.UUID]*db.User                `json:"friend_data"`
	FriendStreams map[uuid.UUID][]*history.AlbumStreams `json:"friend_streams"`
}

type CompareArtistsResp

type CompareArtistsResp struct {
	StreamsByURI  map[string]map[uuid.UUID]int64         `json:"streams_by_uri"`
	RanksByURI    map[string]map[uuid.UUID]int64         `json:"ranks_by_uri"`
	ArtistData    map[string]spotify.FullArtist          `json:"artist_data"`
	FriendData    map[uuid.UUID]*db.User                 `json:"friend_data"`
	FriendStreams map[uuid.UUID][]*history.ArtistStreams `json:"friend_streams"`
}

type CompareTracksResp

type CompareTracksResp struct {
	StreamsByURI map[string]map[uuid.UUID]int64 `json:"streams_by_uri"`
	RanksByURI   map[string]map[uuid.UUID]int64 `json:"ranks_by_uri"`
	TrackData    map[string]db.TrackData        `json:"track_data"`
	FriendData   map[uuid.UUID]*db.User         `json:"friend_data"`
}

type Controller

type Controller struct{}

func (*Controller) AddGuest

func (*Controller) AddGuest(w http.ResponseWriter, r *http.Request)

func (*Controller) AddMember

func (*Controller) AddMember(w http.ResponseWriter, r *http.Request)

func (*Controller) CreateRoom

func (c *Controller) CreateRoom(w http.ResponseWriter, r *http.Request)

func (*Controller) CreateUser

func (c *Controller) CreateUser(w http.ResponseWriter, r *http.Request)

func (*Controller) CurrentUser

func (c *Controller) CurrentUser(w http.ResponseWriter, r *http.Request)

func (*Controller) DeleteMember

func (*Controller) DeleteMember(w http.ResponseWriter, r *http.Request)

func (*Controller) DeleteRoom

func (*Controller) DeleteRoom(w http.ResponseWriter, r *http.Request)

func (*Controller) Devices

func (c *Controller) Devices(w http.ResponseWriter, r *http.Request)

func (*Controller) GetAlbum

func (c *Controller) GetAlbum(w http.ResponseWriter, r *http.Request)

func (*Controller) GetArtist

func (c *Controller) GetArtist(w http.ResponseWriter, r *http.Request)

func (*Controller) GetArtistsByURIs

func (c *Controller) GetArtistsByURIs(w http.ResponseWriter, r *http.Request)

func (*Controller) GetGeneralInfo

func (c *Controller) GetGeneralInfo(w http.ResponseWriter, r *http.Request)

func (*Controller) GetLogsByDate

func (c *Controller) GetLogsByDate(w http.ResponseWriter, r *http.Request)

func (*Controller) GetMissingArtistURIs

func (c *Controller) GetMissingArtistURIs(w http.ResponseWriter, r *http.Request)

func (*Controller) GetMissingArtistURIsByUser

func (c *Controller) GetMissingArtistURIsByUser(w http.ResponseWriter, r *http.Request)

func (*Controller) GetMissingISRCNumbers

func (c *Controller) GetMissingISRCNumbers(w http.ResponseWriter, r *http.Request)

func (*Controller) GetPlayback

func (c *Controller) GetPlayback(w http.ResponseWriter, r *http.Request)

func (*Controller) GetPlaylist

func (c *Controller) GetPlaylist(w http.ResponseWriter, r *http.Request)

func (*Controller) GetQueue

func (c *Controller) GetQueue(w http.ResponseWriter, r *http.Request)

func (*Controller) GetRoom

func (c *Controller) GetRoom(w http.ResponseWriter, r *http.Request)

func (*Controller) GetRoomGuestsAndMembers

func (*Controller) GetRoomGuestsAndMembers(w http.ResponseWriter, r *http.Request)

func (*Controller) GetRoomPermissions

func (c *Controller) GetRoomPermissions(w http.ResponseWriter, r *http.Request)

func (*Controller) GetSpotifyLoginURL

func (c *Controller) GetSpotifyLoginURL(w http.ResponseWriter, r *http.Request)

func (*Controller) GetTableData

func (c *Controller) GetTableData(w http.ResponseWriter, r *http.Request)

func (*Controller) GetToken

func (c *Controller) GetToken(w http.ResponseWriter, r *http.Request)

func (*Controller) GetTracksByURIs

func (c *Controller) GetTracksByURIs(w http.ResponseWriter, r *http.Request)

func (*Controller) GetUncachedTracks

func (c *Controller) GetUncachedTracks(w http.ResponseWriter, r *http.Request)

func (*Controller) GetUserHostedRooms

func (c *Controller) GetUserHostedRooms(w http.ResponseWriter, r *http.Request)

func (*Controller) GetUserJoinedRooms

func (c *Controller) GetUserJoinedRooms(w http.ResponseWriter, r *http.Request)

func (*Controller) GetVersion

func (c *Controller) GetVersion(w http.ResponseWriter, r *http.Request)

func (*Controller) Health

func (c *Controller) Health(w http.ResponseWriter, r *http.Request)

func (*Controller) JoinRoomAsMember

func (*Controller) JoinRoomAsMember(w http.ResponseWriter, r *http.Request)

func (*Controller) Next

func (c *Controller) Next(w http.ResponseWriter, r *http.Request)

func (*Controller) Pause

func (c *Controller) Pause(w http.ResponseWriter, r *http.Request)

func (*Controller) Play

func (c *Controller) Play(w http.ResponseWriter, r *http.Request)

func (*Controller) Previous

func (c *Controller) Previous(w http.ResponseWriter, r *http.Request)

func (*Controller) PushToRoomQueue

func (c *Controller) PushToRoomQueue(w http.ResponseWriter, r *http.Request)

func (*Controller) PushToUserQueue

func (c *Controller) PushToUserQueue(w http.ResponseWriter, r *http.Request)

func (*Controller) SearchArtistsByUser

func (c *Controller) SearchArtistsByUser(w http.ResponseWriter, r *http.Request)

func (*Controller) SearchTracksByUser

func (c *Controller) SearchTracksByUser(w http.ResponseWriter, r *http.Request)

func (*Controller) SearchTracksFromRoom

func (c *Controller) SearchTracksFromRoom(w http.ResponseWriter, r *http.Request)

func (*Controller) SetModerator

func (*Controller) SetModerator(w http.ResponseWriter, r *http.Request)

func (*Controller) SetVolume

func (c *Controller) SetVolume(w http.ResponseWriter, r *http.Request)

func (*Controller) SpotifyAuthRedirect

func (c *Controller) SpotifyAuthRedirect(w http.ResponseWriter, r *http.Request)

func (*Controller) SuggestedTracks

func (c *Controller) SuggestedTracks(w http.ResponseWriter, r *http.Request)

func (*Controller) TracksLeftToProcess

func (c *Controller) TracksLeftToProcess(w http.ResponseWriter, r *http.Request)

func (*Controller) UnlinkSpotify

func (c *Controller) UnlinkSpotify(w http.ResponseWriter, r *http.Request)

func (*Controller) UpdatePassword

func (*Controller) UpdatePassword(w http.ResponseWriter, r *http.Request)

func (*Controller) UserAcceptFriendRequest

func (c *Controller) UserAcceptFriendRequest(w http.ResponseWriter, r *http.Request)

func (*Controller) UserDeleteFriendRequest

func (c *Controller) UserDeleteFriendRequest(w http.ResponseWriter, r *http.Request)

func (*Controller) UserFriendRequestData

func (c *Controller) UserFriendRequestData(w http.ResponseWriter, r *http.Request)

func (*Controller) UserGetFriends

func (c *Controller) UserGetFriends(w http.ResponseWriter, r *http.Request)

func (*Controller) UserHasSpotifyHistory

func (c *Controller) UserHasSpotifyHistory(w http.ResponseWriter, r *http.Request)

func (*Controller) UserPlaylists

func (c *Controller) UserPlaylists(w http.ResponseWriter, r *http.Request)

func (*Controller) UserSendFriendRequest

func (c *Controller) UserSendFriendRequest(w http.ResponseWriter, r *http.Request)

type CreateUserBody

type CreateUserBody struct {
	Username    string `json:"username"`
	DisplayName string `json:"display_name"`
	Password    string `json:"password"`
}

type CreateUserResponse

type CreateUserResponse struct {
	User      user.User `json:"user"`
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
}

type FriendRequestData

type FriendRequestData struct {
	Suggestions      []*db.UserGetFriendSuggestionsRow      `json:"suggestions"`
	SentRequests     []*db.UserGetSentFriendRequestsRow     `json:"sent_requests"`
	ReceivedRequests []*db.UserGetReceivedFriendRequestsRow `json:"received_requests"`
}

type FullLogEntry

type FullLogEntry struct {
	Timestamp time.Time  `json:"timestamp"`
	User      *user.User `json:"user"`
	Endpoint  string     `json:"endpoint"`
	Friend    *user.User `json:"friend"`
}

type GetRoomAuthLevelResponse

type GetRoomAuthLevelResponse struct {
	IsMember    bool `json:"is_member"`
	IsModerator bool `json:"is_moderator"`
	IsHost      bool `json:"is_host"`
}

type GetRoomGuestsAndMembersResponse

type GetRoomGuestsAndMembersResponse struct {
	Guests  []room.Guest  `json:"guests"`
	Members []room.Member `json:"members"`
}

type GetRoomsResponse

type GetRoomsResponse struct {
	Rooms []room.Room `json:"rooms"`
}

type GetSpotifyLoginURLResponse

type GetSpotifyLoginURLResponse struct {
	URL string `json:"url"`
}

type HistoryEntry

type HistoryEntry struct {
	Timestamp       time.Time        `json:"timestamp"`
	TrackName       string           `json:"track_name"`
	AlbumName       string           `json:"album_name"`
	ArtistName      string           `json:"artist_name"`
	MsPlayed        int32            `json:"ms_played"`
	SpotifyTrackUri string           `json:"spotify_track_uri"`
	SpotifyAlbumUri string           `json:"spotify_album_uri"`
	ImageURL        *string          `json:"image_url"`
	Artists         []db.TrackArtist `json:"artists"`
}

type HistoryEntryArtist

type HistoryEntryArtist struct {
	Name string `json:"name"`
	URI  string `json:"uri"`
}

type HistoryResponse

type HistoryResponse struct {
	History     []HistoryEntry `json:"history"`
	LastFetched *time.Time     `json:"last_fetched"`
}

type PermissionLevel

type PermissionLevel int
const (
	IncorrectPassword PermissionLevel = iota
	NotAuthorized
	Guest
	Member
	Moderator
	Host
)

type RequestContext

type RequestContext struct {
	Room            *room.Room
	UserID          string
	GuestID         string
	PermissionLevel PermissionLevel
}

type SetModeratorRequest

type SetModeratorRequest struct {
	UserID      string `json:"user_id"`
	IsModerator bool   `json:"is_moderator"`
}

type StatsController

type StatsController struct{}

func (*StatsController) GetAlbumRankingsByURI

func (c *StatsController) GetAlbumRankingsByURI(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetAlbumStatsByURI

func (c *StatsController) GetAlbumStatsByURI(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetAllHistory

func (c *StatsController) GetAllHistory(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetAllStreamsByURI

func (c *StatsController) GetAllStreamsByURI(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetArtistRankingsByURI

func (c *StatsController) GetArtistRankingsByURI(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetArtistStatsByURI

func (c *StatsController) GetArtistStatsByURI(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetRecentArtistEvents

func (c *StatsController) GetRecentArtistEvents(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetRecentTrackEvents

func (c *StatsController) GetRecentTrackEvents(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetTopAlbumsByTimeframe

func (c *StatsController) GetTopAlbumsByTimeframe(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetTopArtistsByTimeframe

func (c *StatsController) GetTopArtistsByTimeframe(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetTopTracksByTimeframe

func (c *StatsController) GetTopTracksByTimeframe(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetTrackRankingsByURI

func (c *StatsController) GetTrackRankingsByURI(w http.ResponseWriter, r *http.Request)

func (*StatsController) GetTrackStatsByURI

func (c *StatsController) GetTrackStatsByURI(w http.ResponseWriter, r *http.Request)

func (*StatsController) UploadHistory

func (c *StatsController) UploadHistory(w http.ResponseWriter, r *http.Request)

func (*StatsController) UserCompareFriendTopAlbums

func (c *StatsController) UserCompareFriendTopAlbums(w http.ResponseWriter, r *http.Request)

func (*StatsController) UserCompareFriendTopArtists

func (c *StatsController) UserCompareFriendTopArtists(w http.ResponseWriter, r *http.Request)

func (*StatsController) UserCompareFriendTopTracks

func (c *StatsController) UserCompareFriendTopTracks(w http.ResponseWriter, r *http.Request)

type StatsControllerInterface

type StatsControllerInterface interface {
	GetTopAlbumsByMonth(w http.ResponseWriter, r *http.Request)
	GetTopArtistsByMonth(w http.ResponseWriter, r *http.Request)
	GetTopTracksByMonth(w http.ResponseWriter, r *http.Request)
}

type Stream

type Stream struct {
	Timestamp       time.Time `json:"timestamp"`
	MsPlayed        int       `json:"ms_played"`
	TrackName       string    `json:"track_name"`
	AlbumName       string    `json:"album_name"`
	SpotifyTrackUri string    `json:"spotify_track_uri"`
	SpotifyAlbumUri string    `json:"spotify_album_uri"`
	ISRC            *string   `json:"isrc,omitempty"`
}

type TimeframeRanking

type TimeframeRanking struct {
	Year                 int               `json:"year"`
	Month                int               `json:"month"`
	Position             int               `json:"position"`
	StartDateUnixSeconds int64             `json:"start_date_unix_seconds"`
	Timeframe            history.Timeframe `json:"timeframe"`
}

type TokenResponse

type TokenResponse struct {
	Token     string     `json:"token"`
	ExpiresAt time.Time  `json:"expires_at"`
	User      *user.User `json:"user"`
}

type TopAlbumsResponse

type TopAlbumsResponse struct {
	Rankings  []*history.AlbumRankings     `json:"rankings"`
	AlbumData map[string]spotify.FullAlbum `json:"album_data"`
}

type TopArtistsResponse

type TopArtistsResponse struct {
	Rankings   []*history.ArtistRankings     `json:"rankings"`
	ArtistData map[string]spotify.FullArtist `json:"artist_data"`
	TrackData  map[string]db.TrackData       `json:"track_data"`
}

type TopTracksResponse

type TopTracksResponse struct {
	Rankings  []*history.TrackRankings `json:"rankings"`
	TrackData map[string]db.TrackData  `json:"track_data"`
}

type TrackStatsResponse

type TrackStatsResponse struct {
	Track   *db.TrackData `json:"track"`
	Streams []*Stream     `json:"streams"`
}

type UpdatePasswordRequest

type UpdatePasswordRequest struct {
	NewPassword string `json:"new_password"`
}

Jump to

Keyboard shortcuts

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