Do not report OpenSubsonic extra fields for selected legacy clients. This made DSub behave badly. fixes #356
This commit is contained in:
@@ -93,7 +93,7 @@ namespace API::Subsonic
|
||||
}
|
||||
}
|
||||
|
||||
Response::Node createSongNode(const Track::pointer& track, Session& dbSession, const User::pointer& user)
|
||||
Response::Node createSongNode(RequestContext& context, const Track::pointer& track, const User::pointer& user)
|
||||
{
|
||||
Response::Node trackResponse;
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace API::Subsonic
|
||||
trackResponse.setAttribute("starred", StringUtils::toISO8601String(dateTime));
|
||||
|
||||
// Report the first GENRE for this track
|
||||
const ClusterType::pointer genreClusterType{ ClusterType::find(dbSession, "GENRE") };
|
||||
const ClusterType::pointer genreClusterType{ ClusterType::find(context.dbSession, "GENRE") };
|
||||
if (genreClusterType)
|
||||
{
|
||||
auto clusters{ track->getClusterGroups({genreClusterType}, 1) };
|
||||
@@ -162,6 +162,9 @@ namespace API::Subsonic
|
||||
}
|
||||
|
||||
// OpenSubsonic specific fields (must always be set)
|
||||
if (!context.enableOpenSubsonic)
|
||||
return trackResponse;
|
||||
|
||||
trackResponse.setAttribute("mediaType", "song");
|
||||
|
||||
{
|
||||
@@ -179,9 +182,9 @@ namespace API::Subsonic
|
||||
TrackArtistLink::FindParameters params;
|
||||
params.setTrack(track->getId());
|
||||
|
||||
for (const TrackArtistLinkId linkId : TrackArtistLink::find(dbSession, params).results)
|
||||
for (const TrackArtistLinkId linkId : TrackArtistLink::find(context.dbSession, params).results)
|
||||
{
|
||||
TrackArtistLink::pointer link{ TrackArtistLink::find(dbSession, linkId) };
|
||||
TrackArtistLink::pointer link{ TrackArtistLink::find(context.dbSession, linkId) };
|
||||
// Don't report artists nor release artists as they are set in dedicated fields
|
||||
if (link && link->getType() != TrackArtistLinkType::Artist && link->getType() != TrackArtistLinkType::ReleaseArtist)
|
||||
trackResponse.addArrayChild("contributors", createContributorNode(link));
|
||||
@@ -196,9 +199,9 @@ namespace API::Subsonic
|
||||
params.setTrack(track->getId());
|
||||
params.setLinkType(type);
|
||||
|
||||
for (const TrackArtistLinkId linkId : TrackArtistLink::find(dbSession, params).results)
|
||||
for (const TrackArtistLinkId linkId : TrackArtistLink::find(context.dbSession, params).results)
|
||||
{
|
||||
TrackArtistLink::pointer link{ TrackArtistLink::find(dbSession, linkId) };
|
||||
TrackArtistLink::pointer link{ TrackArtistLink::find(context.dbSession, linkId) };
|
||||
if (link)
|
||||
trackResponse.addArrayChild(nodeName, createArtistNode(link->getArtist()));
|
||||
}
|
||||
@@ -215,14 +218,14 @@ namespace API::Subsonic
|
||||
{
|
||||
trackResponse.createEmptyArrayValue(field);
|
||||
|
||||
ClusterType::pointer clusterType{ ClusterType::find(dbSession, clusterTypeName) };
|
||||
ClusterType::pointer clusterType{ ClusterType::find(context.dbSession, clusterTypeName) };
|
||||
if (clusterType)
|
||||
{
|
||||
Cluster::FindParameters params;
|
||||
params.setTrack(track->getId());
|
||||
params.setClusterType(clusterType->getId());
|
||||
|
||||
for (const auto& cluster : Cluster::find(dbSession, params).results)
|
||||
for (const auto& cluster : Cluster::find(context.dbSession, params).results)
|
||||
trackResponse.addArrayValue(field, std::get<std::string>(cluster));
|
||||
}
|
||||
} };
|
||||
@@ -237,7 +240,7 @@ namespace API::Subsonic
|
||||
params.setTrack(track->getId());
|
||||
params.setClusterType(genreClusterType->getId());
|
||||
|
||||
for (const auto& cluster : Cluster::find(dbSession, params).results)
|
||||
for (const auto& cluster : Cluster::find(context.dbSession, params).results)
|
||||
trackResponse.addArrayChild("genres", createItemGenreNode(std::get<std::string>(cluster)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user