Commit 78cd55fd authored by Benjamin REIS's avatar Benjamin REIS

make soci-users-with-phones-request mandatory to start presence server and...

make soci-users-with-phones-request mandatory to start presence server and soci-user-with-phone-request optionnal
parent 38efb045
......@@ -45,14 +45,16 @@ void SociAuthDB::declareConfig(GenericStruct *mc) {
{String, "soci-user-with-phone-request",
"Soci SQL request to execute to obtain the username associated with a phone alias.\n"
"Named parameters are:\n -':phone' : the phone number to search for.\n"
"The use of the :phone parameter is mandatory.",
"select login from accounts where phone = :phone"},
"The use of the :phone parameter is mandatory.\n"
"Example : select login from accounts where phone = :phone ",
""},
{String, "soci-users-with-phones-request",
"Soci SQL request to execute to obtain the usernames associated with phones aliases.\n"
"Named parameters are:\n -':phones' : the phones to search for.\n"
"The use of the :phones parameter is mandatory.\n"
"If you use phone number linked accounts you'll need to select login, domain, phone in your request for flexisip to work.",
"select login, domain, phone from accounts where phone in (:phones)"},
"If you use phone number linked accounts you'll need to select login, domain, phone in your request for flexisip to work."
"Example : select login, domain, phone from accounts where phone in (:phones)",
""},
{Integer, "soci-poolsize",
"Size of the pool of connections that Soci will use. We open a thread for each DB query, and this pool will "
......@@ -211,8 +213,11 @@ void SociAuthDB::getUserWithPhoneWithPool(const std::string &phone, const std::s
SLOGD << "[SOCI] Pool acquired in " << DURATION_MS(start, stop) << "ms";
start = stop;
*sql << get_user_with_phone_request, into(user), use(phone, "phone");
if(get_user_with_phone_request != "") {
*sql << get_user_with_phone_request, into(user), use(phone, "phone");
} else {
*sql << get_users_with_phones_request, into(user), use(phone, "phones");
}
stop = steady_clock::now();
if (!user.empty()) {
SLOGD << "[SOCI] Got user for " << phone << " in " << DURATION_MS(start, stop) << "ms";
......
......@@ -144,11 +144,17 @@ PresenceServer::~PresenceServer() {
void PresenceServer::_start(bool withThread) throw(FlexisipException) {
if (!mEnabled) return;
list<string> transports = GenericManager::get()
->getRoot()
->get<GenericStruct>("presence-server")
->get<ConfigStringList>("transports")
->read();
GenericStruct *cr = GenericManager::get()->getRoot();
std::string get_users_with_phones_request = cr->get<GenericStruct>("module::Authentication")
->get<ConfigString>("soci-users-with-phones-request")
->read();
if(get_users_with_phones_request == "") {
LOGF("Unable to start presence server : soci-users-with-phones-request is not precised in flexisip.conf, please fix it.");
}
list<string> transports = cr->get<GenericStruct>("presence-server")
->get<ConfigStringList>("transports")
->read();
for (auto it = transports.begin(); it != transports.end(); ++it) {
string transport = *it;
......
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