Web interface: Use [identity] name instead of hostname when set
This commit is contained in:
parent
cedac0a9b0
commit
c4eda8c23b
3 changed files with 17 additions and 7 deletions
|
@ -94,7 +94,15 @@ void APIServer::serve_instances(Server *server, Server::session *session, struct
|
|||
Value instance;
|
||||
instance.SetObject();
|
||||
instance.AddMember("id", id.c_str(), json.GetAllocator());
|
||||
instance.AddMember("name", id.c_str(), json.GetAllocator());
|
||||
|
||||
std::string name = get_config(m_config, id, "identity.name");
|
||||
if (name.empty() || name == "Spectrum 2 Transport") {
|
||||
instance.AddMember("name", id.c_str(), json.GetAllocator());
|
||||
}
|
||||
else {
|
||||
statuses.push_back(name);
|
||||
instance.AddMember("name", statuses.back().c_str(), json.GetAllocator());
|
||||
}
|
||||
|
||||
std::string status = server->send_command(id, "status");
|
||||
if (status.empty()) {
|
||||
|
@ -119,7 +127,9 @@ void APIServer::serve_instances(Server *server, Server::session *session, struct
|
|||
usernames.push_back(username);
|
||||
instance.AddMember("registered", !username.empty(), json.GetAllocator());
|
||||
instance.AddMember("username", usernames.back().c_str(), json.GetAllocator());
|
||||
instance.AddMember("frontend", is_slack(m_config, id) ? "slack" : "xmpp", json.GetAllocator());
|
||||
|
||||
usernames.push_back(get_config(m_config, id, "service.frontend"));
|
||||
instance.AddMember("frontend", usernames.back().c_str(), json.GetAllocator());
|
||||
|
||||
instances.PushBack(instance, json.GetAllocator());
|
||||
}
|
||||
|
|
|
@ -501,7 +501,7 @@ static void handleConnected(boost::shared_ptr<Swift::Connection> m_conn, const s
|
|||
}
|
||||
}
|
||||
|
||||
bool is_slack(ManagerConfig *config, const std::string &jid) {
|
||||
std::string get_config(ManagerConfig *config, const std::string &jid, const std::string &key) {
|
||||
path p(CONFIG_STRING(config, "service.config_directory"));
|
||||
|
||||
try {
|
||||
|
@ -528,16 +528,16 @@ bool is_slack(ManagerConfig *config, const std::string &jid) {
|
|||
continue;
|
||||
}
|
||||
|
||||
return CONFIG_STRING(&cfg, "service.frontend") == "slack";
|
||||
return CONFIG_STRING(&cfg, key);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (const filesystem_error& ex) {
|
||||
return false;
|
||||
return "";
|
||||
}
|
||||
|
||||
return false;
|
||||
return "";
|
||||
}
|
||||
|
||||
void ask_local_server(ManagerConfig *config, Swift::BoostNetworkFactories &networkFactories, const std::string &jid, const std::string &message) {
|
||||
|
|
|
@ -51,7 +51,7 @@ void stop_instances(ManagerConfig *config, const std::string &_jid = "");
|
|||
int show_status(ManagerConfig *config);
|
||||
|
||||
void ask_local_server(ManagerConfig *config, Swift::BoostNetworkFactories &networkFactories, const std::string &jid, const std::string &message);
|
||||
bool is_slack(ManagerConfig *config, const std::string &jid);
|
||||
std::string get_config(ManagerConfig *config, const std::string &jid, const std::string &key);
|
||||
|
||||
std::vector<std::string> show_list(ManagerConfig *config, bool show = true);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue