diff --git a/tinyphone/consts.h b/tinyphone/consts.h index a1e2bcb..06cd72b 100644 --- a/tinyphone/consts.h +++ b/tinyphone/consts.h @@ -32,4 +32,4 @@ #define MSG_CONTACT_IT_SUPPORT "ERROR Connecting Audio Device, Please Contact Floor IT Support" #define MSG_DEVICE_ERROR "Audio Device Test Failed, Please Contact Floor IT Support" -#endif \ No newline at end of file +#endif diff --git a/tinyphone/net.cpp b/tinyphone/net.cpp index 51647b7..9528e61 100644 --- a/tinyphone/net.cpp +++ b/tinyphone/net.cpp @@ -172,6 +172,20 @@ namespace tp { return response; } + std::string urldecode(std::string data){ + std::string out = data; + CURL *curl = curl_easy_init(); + if(curl) { + char *decoded = curl_easy_unescape(curl,data.c_str(), data.length(), NULL); + if(decoded) { + out = std::string(decoded); + curl_free(decoded); + } + curl_easy_cleanup(curl); + } + return out; + } + std::string local_ip_address() { boost::asio::io_service io_service; boost::asio::ip::tcp::resolver resolver(io_service); diff --git a/tinyphone/net.h b/tinyphone/net.h index f5d5ebd..87e45f6 100644 --- a/tinyphone/net.h +++ b/tinyphone/net.h @@ -25,6 +25,8 @@ namespace tp { tp::HttpResponse http_post(std::string url, std::string body) throw (std::exception); + std::string urldecode(std::string data); + std::string local_ip_address(); bool is_tcp_port_in_use(unsigned short port); @@ -33,4 +35,4 @@ namespace tp { } -#endif \ No newline at end of file +#endif diff --git a/tinyphone/server.cpp b/tinyphone/server.cpp index 8c3723a..6eb0567 100644 --- a/tinyphone/server.cpp +++ b/tinyphone/server.cpp @@ -243,8 +243,8 @@ void TinyPhoneHttpServer::Start() { } catch (pj::Error& e) { tp::MetricsClient.increment("api.login.error.pjsua_error"); - CROW_LOG_ERROR << "Exception catched : " << e.reason; - return tp::response(500, DEFAULT_HTTP_SERVER_ERROR_REPONSE); + CROW_LOG_ERROR << "Exception catched : " << e.reason; + return tp::response(500, DEFAULT_HTTP_SERVER_ERROR_REPONSE); } catch (std::domain_error& e) { tp::MetricsClient.increment("api.login.error.device_error"); @@ -256,9 +256,9 @@ void TinyPhoneHttpServer::Start() { { "message", response_msg }, { "result", 503 } }); - } catch (...){ - return tp::response(500, DEFAULT_HTTP_SERVER_ERROR_REPONSE); - } + } catch (...){ + return tp::response(500, DEFAULT_HTTP_SERVER_ERROR_REPONSE); + } }); CROW_ROUTE(app, "/accounts") @@ -591,10 +591,11 @@ void TinyPhoneHttpServer::Start() { CROW_ROUTE(app, "/calls//dtmf/") .methods("POST"_method) - ([&phone](int call_id, string dtmf_digits) { + ([&phone](int call_id, string dtmf_string) { pj_thread_auto_register(); try { + string dtmf_digits = urldecode(dtmf_string); SIPCall* call = phone.CallById(call_id); if (call == nullptr) { return tp::response(400, {