Store each client's play queue in the database
The queue lived in memory and was shared by all clients, so a restart or a finished sync cleared it. Every client now has its own queue in the new queue and queue_song tables (added to the undeployed migration 000006). The music endpoints return the queue ID in the X-Queue-Id header and expect it back. A request without an ID, or with an ended one, starts a new queue. /music/reset ends the queue and returns a new ID, and a sync ends all running queues. Ended queues are kept as history. The deprecated legacy routes without the /api/v1 prefix are removed.
This commit is contained in:
1 parent
b5dc42b654
commit
a705d7b476
28 files changed
+1103
-320
No files matched your search
@@ -11,8 +11,8 @@ import (
|
||||
"github.com/danielgtaylor/huma/v2"
|
||||
)
|
||||
|
||||
func (s *Server) registerSync(a apis) {
|
||||
registry := a.v1.OpenAPI().Components.Schemas
|
||||
func (s *Server) registerSync(a huma.API) {
|
||||
registry := a.OpenAPI().Components.Schemas
|
||||
progress := huma.Operation{
|
||||
OperationID: "get-sync-progress",
|
||||
Method: http.MethodGet,
|
||||
@@ -30,7 +30,7 @@ func (s *Server) registerSync(a apis) {
|
||||
},
|
||||
},
|
||||
}
|
||||
register(s, a, route{op: progress, legacyPath: "/sync/progress"},
|
||||
register(s, a, route{op: progress},
|
||||
func(ctx context.Context, _ *struct{}) (*jsonBody[any], error) {
|
||||
if s.sync.IsSyncing() {
|
||||
return ok[any](s.sync.Progress(), nil)
|
||||
@@ -49,7 +49,6 @@ func (s *Server) registerSync(a apis) {
|
||||
Tags: []string{"sync"},
|
||||
Errors: []int{http.StatusLocked},
|
||||
},
|
||||
legacyPath: path,
|
||||
}, func(ctx context.Context, _ *struct{}) (*jsonBody[string], error) {
|
||||
message := "Start syncing soundtracks"
|
||||
if full {
|
||||
@@ -78,7 +77,7 @@ func (s *Server) registerSync(a apis) {
|
||||
Tags: []string{"sync"},
|
||||
Hidden: true,
|
||||
}
|
||||
register(s, a, route{op: reset, legacyPath: "/sync/reset", locked: true},
|
||||
register(s, a, route{op: reset, locked: true},
|
||||
func(ctx context.Context, _ *struct{}) (*jsonBody[string], error) {
|
||||
logging.GetLogger().Info("Resetting soundtracks database")
|
||||
return ok("Soundtracks and songs are deleted from the database", s.sync.ResetDB(ctx))
|
||||
|
||||
Reference in new issue
Block a user