🎧 Your Personal Streaming Service
Go airsonicmadsonicmedia-servermusicmusic-servernavidromeopensubsonicraspberry-piself-hostedstreamerstreaming-apistreaming-audiosubsonicsubsonic-server
fix(playlist): update smart playlist rules during metadata update
Deluan55e10b9c7787
diff --git a/core/playlists/rest_adapter.go b/core/playlists/rest_adapter.goindex c9cd4c136..3fecda0d5 100644--- a/core/playlists/rest_adapter.go+++ b/core/playlists/rest_adapter.go@@ -97,5 +97,7 @@ func (s *playlists) updatePlaylistEntity(ctx context.Context, id string, entityif entity.OwnerID != "" {current.OwnerID = entity.OwnerID}+ // Apply smart playlist rules update+ current.Rules = entity.Rulesreturn s.updateMetadata(ctx, s.ds, current, &entity.Name, &entity.Comment, &entity.Public)}diff --git a/core/playlists/rest_adapter_test.go b/core/playlists/rest_adapter_test.goindex 29db2fc33..70ca8a9e4 100644--- a/core/playlists/rest_adapter_test.go+++ b/core/playlists/rest_adapter_test.go@@ -125,6 +125,22 @@ var _ = Describe("REST Adapter", func() {Expect(err).To(Equal(rest.ErrPermissionDenied))})+ It("updates smart playlist rules", func() {+ mockPlsRepo.Data["smart-1"] = &model.Playlist{+ ID: "smart-1",+ Name: "Smart Playlist",+ OwnerID: "user-1",+ Rules: &criteria.Criteria{Expression: criteria.Contains{"title": "old"}},+ }+ ctx = request.WithUser(ctx, model.User{ID: "user-1", IsAdmin: false})+ repo = ps.NewRepository(ctx).(rest.Persistable)+ newRules := &criteria.Criteria{Expression: criteria.Contains{"title": "new"}}+ pls := &model.Playlist{Name: "Smart Playlist", Rules: newRules}+ err := repo.Update("smart-1", pls)+ Expect(err).ToNot(HaveOccurred())+ Expect(mockPlsRepo.Last.Rules).To(Equal(newRules))+ })+It("returns rest.ErrNotFound when playlist doesn't exist", func() {ctx = request.WithUser(ctx, model.User{ID: "user-1", IsAdmin: false})repo = ps.NewRepository(ctx).(rest.Persistable)