mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-02 11:58:27 +00:00
Include "environment" information in a successful auth response --
includes http server port, api version, and sdk version.
This commit is contained in:
parent
a66c14e931
commit
fc84edf72f
@ -113,6 +113,7 @@ namespace key {
|
||||
static const std::string relative = "relative";
|
||||
static const std::string password = "password";
|
||||
static const std::string authenticated = "authenticated";
|
||||
static const std::string environment = "environment";
|
||||
static const std::string playlist_id = "playlist_id";
|
||||
static const std::string playlist_name = "playlist_name";
|
||||
static const std::string subquery = "subquery";
|
||||
@ -121,6 +122,8 @@ namespace key {
|
||||
static const std::string sort_orders = "sort_orders";
|
||||
static const std::string predicate_category = "predicate_category";
|
||||
static const std::string predicate_id = "predicate_id";
|
||||
static const std::string sdk_version = "sdk_version";
|
||||
static const std::string api_version = "api_version";
|
||||
}
|
||||
|
||||
namespace value {
|
||||
@ -192,4 +195,6 @@ static auto REPEAT_MODE_TO_STRING = makeBimap<musik::core::sdk::RepeatMode, std:
|
||||
{ musik::core::sdk::RepeatNone, "none" },
|
||||
{ musik::core::sdk::RepeatTrack, "track" },
|
||||
{ musik::core::sdk::RepeatList, "list" }
|
||||
});
|
||||
});
|
||||
|
||||
static const int ApiVersion = 12;
|
@ -96,6 +96,15 @@ static std::shared_ptr<T> jsonToIntArray(json& arr) {
|
||||
});
|
||||
}
|
||||
|
||||
static json getEnvironment(Context& context) {
|
||||
return {
|
||||
{ prefs::http_server_enabled, context.prefs->GetBool(prefs::http_server_enabled.c_str()) },
|
||||
{ prefs::http_server_port, context.prefs->GetInt(prefs::http_server_port.c_str()) },
|
||||
{ key::sdk_version, musik::core::sdk::SdkVersion },
|
||||
{ key::api_version, ApiVersion }
|
||||
};
|
||||
}
|
||||
|
||||
/* IMPLEMENTATION */
|
||||
|
||||
WebSocketServer::WebSocketServer(Context& context)
|
||||
@ -215,9 +224,10 @@ void WebSocketServer::HandleAuthentication(connection_hdl connection, json& requ
|
||||
this->connections[connection] = true; /* mark as authed */
|
||||
|
||||
this->RespondWithOptions(
|
||||
connection,
|
||||
request,
|
||||
json({ { key::authenticated, true } }));
|
||||
connection, request, json({
|
||||
{ key::authenticated, true },
|
||||
{ key::environment, getEnvironment(context) }
|
||||
}));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -871,10 +881,7 @@ void WebSocketServer::RespondWithPlayTracksByCategory(connection_hdl connection,
|
||||
}
|
||||
|
||||
void WebSocketServer::RespondWithEnvironment(connection_hdl connection, json& request) {
|
||||
this->RespondWithOptions(connection, request, {
|
||||
{ prefs::http_server_enabled, context.prefs->GetBool(prefs::http_server_enabled.c_str()) },
|
||||
{ prefs::http_server_port, context.prefs->GetInt(prefs::http_server_port.c_str()) }
|
||||
});
|
||||
this->RespondWithOptions(connection, request, getEnvironment(context));
|
||||
}
|
||||
|
||||
void WebSocketServer::RespondWithCurrentTime(connection_hdl connection, json& request) {
|
||||
|
Loading…
Reference in New Issue
Block a user