Added OpenSubsonic API: added missing tokenInfo endpoint, fixes #838
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user