Added OpenSubsonic API: added missing tokenInfo endpoint, fixes #838

This commit is contained in:
emeric
2026-06-02 09:57:19 +02:00
parent 8c72fb7b5a
commit 531c5ca24d
3 changed files with 16 additions and 0 deletions
@@ -135,6 +135,7 @@ namespace lms::api::subsonic
{ "/ping", { handlePingRequest } },
{ "/getLicense", { handleGetLicenseRequest } },
{ "/getOpenSubsonicExtensions", { handleGetOpenSubsonicExtensions, AuthenticationMode::Unauthenticated } },
{ "/tokenInfo", { handleTokenInfoRequest } },
// Browsing
{ "/getMusicFolders", { handleGetMusicFoldersRequest } },
@@ -19,6 +19,9 @@
#include <array>
#include "database/Session.hpp"
#include "database/objects/User.hpp"
#include "endpoints/System.hpp"
namespace lms::api::subsonic
@@ -40,6 +43,17 @@ namespace lms::api::subsonic
return response;
}
Response handleTokenInfoRequest(RequestContext& context)
{
Response response{ Response::createOkResponse(context.getServerProtocolVersion()) };
Response::Node& tokenInfoNode{ response.createNode("tokenInfo") };
auto transaction{ context.getDbSession().createReadTransaction() };
tokenInfoNode.setAttribute("username", std::string{ context.getUser()->getLoginName() });
return response;
}
Response handleGetOpenSubsonicExtensions(RequestContext& context)
{
Response response{ Response::createOkResponse(context.getServerProtocolVersion()) };
@@ -27,4 +27,5 @@ namespace lms::api::subsonic
Response handlePingRequest(RequestContext& context);
Response handleGetLicenseRequest(RequestContext& context);
Response handleGetOpenSubsonicExtensions(RequestContext& context);
Response handleTokenInfoRequest(RequestContext& context);
} // namespace lms::api::subsonic