Changeset - cd005935e254
[Not reviewed]
0 1 0
Jan Kaluza - 10 years ago 2016-02-19 17:16:34
jkaluza@redhat.com
Web interface: Allow joining rooms with white-spaces in the nickname
1 file changed with 1 insertions and 0 deletions:
0 comments (0 inline, 0 general)
spectrum_manager/src/APIServer.cpp
Show inline comments
 
@@ -292,48 +292,49 @@ void APIServer::serve_instances_register(Server *server, Server::session *sessio
 
				send_ack(conn, true, response);
 
				return;
 
			}
 
		}
 
	}
 
}
 

	
 
void APIServer::serve_instances_join_room(Server *server, Server::session *session, struct mg_connection *conn, struct http_message *hm) {
 
	std::string uri(hm->uri.p, hm->uri.len);
 
	std::string instance = uri.substr(uri.rfind("/") + 1);
 

	
 
	UserInfo info;
 
	m_storage->getUser(session->user, info);
 

	
 
	std::string username = "";
 
	int type = (int) TYPE_STRING;
 
	m_storage->getUserSetting(info.id, instance, type, username);
 

	
 
	if (username.empty()) {
 
		send_ack(conn, true, "You are not registered to this Spectrum 2 instance.");
 
		return;
 
	}
 

	
 
	std::string name = get_http_var(hm, "name");
 
	boost::replace_all(name, " ", "_");
 
	std::string legacy_room = get_http_var(hm, "legacy_room");
 
	std::string legacy_server = get_http_var(hm, "legacy_server");
 
	std::string frontend_room = get_http_var(hm, "frontend_room");
 

	
 
	std::string response = server->send_command(instance, "join_room " +
 
		username + " " + name + " " + legacy_room + " " + legacy_server + " " + frontend_room);
 

	
 
	if (response.find("Joined the room") == std::string::npos) {
 
		send_ack(conn, true, response);
 
	}
 
	else {
 
		send_ack(conn, false, response);
 
	}
 
}
 

	
 
void APIServer::serve_instances_leave_room(Server *server, Server::session *session, struct mg_connection *conn, struct http_message *hm) {
 
	std::string uri(hm->uri.p, hm->uri.len);
 
	std::string instance = uri.substr(uri.rfind("/") + 1);
 

	
 
	UserInfo info;
 
	m_storage->getUser(session->user, info);
 

	
 
	std::string username = "";
 
	int type = (int) TYPE_STRING;
0 comments (0 inline, 0 general)