Skip to content

Commit

Permalink
Subsonic API: returns the created/updated playlist in createPlaylist …
Browse files Browse the repository at this point in the history
…endpoint. ref #393
  • Loading branch information
epoupon committed Dec 13, 2023
1 parent 3ad990a commit 5257f68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libs/subsonic/impl/ProtocolVersion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace API::Subsonic
};

static inline constexpr ProtocolVersion defaultServerProtocolVersion{ 1, 16, 0 };
static inline constexpr std::string_view serverVersion{ "4" };
static inline constexpr std::string_view serverVersion{ "5" };
}

namespace StringUtils
Expand Down
13 changes: 11 additions & 2 deletions src/libs/subsonic/impl/entrypoints/Playlists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace API::Subsonic
std::vector<TrackId> trackIds{ getMultiParametersAs<TrackId>(context.parameters, "songId") };

if (!name && !id)
throw RequiredParameterMissingError{ "name or id" };
throw RequiredParameterMissingError{ "name or playlistId" };

auto transaction{ context.dbSession.createWriteTransaction() };

Expand Down Expand Up @@ -125,7 +125,16 @@ namespace API::Subsonic
context.dbSession.create<TrackListEntry>(track, tracklist);
}

return Response::createOkResponse(context.serverProtocolVersion);
Response response{ Response::createOkResponse(context.serverProtocolVersion) };
Response::Node playlistNode{ createPlaylistNode(tracklist, context.dbSession) };

auto entries{ tracklist->getEntries() };
for (const TrackListEntry::pointer& entry : entries)
playlistNode.addArrayChild("entry", createSongNode(context, entry->getTrack(), user));

response.addNode("playlist", std::move(playlistNode));

return response;
}

Response handleUpdatePlaylistRequest(RequestContext& context)
Expand Down

0 comments on commit 5257f68

Please sign in to comment.