Commit 957a7239 authored by Gabriel Margiani's avatar Gabriel Margiani

Added default url alias to phonebook

parent 1c4fd526
......@@ -80,7 +80,8 @@ void p3::phonebook::add(const std::string& nr) {
name = match.str(1);
}
if (std::regex_search(nr, match, rnr) && match.size() > 2) {
if (match.str(2) == conf->get_string("phonebook:default_uri")) {
if (match.str(2) == conf->get_string("phonebook:default_uri") ||
match.str(2) == conf->get_string("phonebook:default_uri_alias")) {
num = match.str(1);
} else {
num = "<sip:" + match.str(1) + "@" + match.str(2) + ">";
......@@ -179,9 +180,14 @@ std::string p3::phonebook::normalize_number(std::string nr) {
normalize(nr);
std::regex r("<sip:(.*)@" +
conf->get_string("phonebook:default_uri") + ">");
std::regex r2("<sip:(.*)@" +
conf->get_string("phonebook:default_uri_alias") + ">");
std::smatch match;
if (std::regex_search(nr, match, r) && match.size() > 1) {
return match.str(1);
}
if (std::regex_search(nr, match, r2) && match.size() > 1) {
return match.str(1);
}
return nr;
}
......@@ -34,6 +34,7 @@ std::map<std::string, std::string> p3::server::default_config {
{"account:username", "test"},
{"account:password", "pass"},
{"phonebook:default_uri", "3phone.com"},
{"phonebook:default_uri_alias", "1.1.1.1"},
{"phonebook:filename", "~/.3phone/phonebook"},
{"phonebook:auto_add", "false"},
{"phonebook:auto_add_unanswered", "false"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment