mirror of
https://github.com/navidrome/navidrome.git
synced 2025-06-02 08:31:27 +03:00
parent
91a91f7e06
commit
675cbe11b3
@ -141,7 +141,7 @@ func (c *PlaylistsController) DeletePlaylist(w http.ResponseWriter, r *http.Requ
|
|||||||
return newResponse(), nil
|
return newResponse(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PlaylistsController) update(ctx context.Context, playlistId string, name *string, idsToAdd []string, idxToRemove []int) error {
|
func (c *PlaylistsController) update(ctx context.Context, playlistId string, name *string, comment *string, public *bool, idsToAdd []string, idxToRemove []int) error {
|
||||||
return c.ds.WithTx(func(tx model.DataStore) error {
|
return c.ds.WithTx(func(tx model.DataStore) error {
|
||||||
pls, err := tx.Playlist(ctx).Get(playlistId)
|
pls, err := tx.Playlist(ctx).Get(playlistId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -156,6 +156,13 @@ func (c *PlaylistsController) update(ctx context.Context, playlistId string, nam
|
|||||||
if name != nil {
|
if name != nil {
|
||||||
pls.Name = *name
|
pls.Name = *name
|
||||||
}
|
}
|
||||||
|
if comment != nil {
|
||||||
|
pls.Comment = *comment
|
||||||
|
}
|
||||||
|
if public != nil {
|
||||||
|
pls.Public = *public
|
||||||
|
}
|
||||||
|
|
||||||
newTracks := model.MediaFiles{}
|
newTracks := model.MediaFiles{}
|
||||||
for i, t := range pls.Tracks {
|
for i, t := range pls.Tracks {
|
||||||
if utils.IntInSlice(i, idxToRemove) {
|
if utils.IntInSlice(i, idxToRemove) {
|
||||||
@ -180,11 +187,18 @@ func (c *PlaylistsController) UpdatePlaylist(w http.ResponseWriter, r *http.Requ
|
|||||||
}
|
}
|
||||||
songsToAdd := utils.ParamStrings(r, "songIdToAdd")
|
songsToAdd := utils.ParamStrings(r, "songIdToAdd")
|
||||||
songIndexesToRemove := utils.ParamInts(r, "songIndexToRemove")
|
songIndexesToRemove := utils.ParamInts(r, "songIndexToRemove")
|
||||||
|
|
||||||
var plsName *string
|
var plsName *string
|
||||||
if len(r.URL.Query()["name"]) > 0 {
|
if s, ok := r.URL.Query()["name"]; ok {
|
||||||
s := r.URL.Query()["name"][0]
|
plsName = &s[0]
|
||||||
plsName = &s
|
}
|
||||||
|
var comment *string
|
||||||
|
if c, ok := r.URL.Query()["comment"]; ok {
|
||||||
|
comment = &c[0]
|
||||||
|
}
|
||||||
|
var public *bool
|
||||||
|
if _, ok := r.URL.Query()["public"]; ok {
|
||||||
|
p := utils.ParamBool(r, "public", false)
|
||||||
|
public = &p
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug(r, "Updating playlist", "id", playlistId)
|
log.Debug(r, "Updating playlist", "id", playlistId)
|
||||||
@ -194,7 +208,7 @@ func (c *PlaylistsController) UpdatePlaylist(w http.ResponseWriter, r *http.Requ
|
|||||||
log.Trace(r, fmt.Sprintf("-- Adding: '%v'", songsToAdd))
|
log.Trace(r, fmt.Sprintf("-- Adding: '%v'", songsToAdd))
|
||||||
log.Trace(r, fmt.Sprintf("-- Removing: '%v'", songIndexesToRemove))
|
log.Trace(r, fmt.Sprintf("-- Removing: '%v'", songIndexesToRemove))
|
||||||
|
|
||||||
err = c.update(r.Context(), playlistId, plsName, songsToAdd, songIndexesToRemove)
|
err = c.update(r.Context(), playlistId, plsName, comment, public, songsToAdd, songIndexesToRemove)
|
||||||
if err == model.ErrNotAuthorized {
|
if err == model.ErrNotAuthorized {
|
||||||
return nil, newError(responses.ErrorAuthorizationFail)
|
return nil, newError(responses.ErrorAuthorizationFail)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user