diff --git a/kamailio/presence_notify_sync-role.cfg b/kamailio/presence_notify_sync-role.cfg index 23db64b..9f2d0f4 100644 --- a/kamailio/presence_notify_sync-role.cfg +++ b/kamailio/presence_notify_sync-role.cfg @@ -92,8 +92,8 @@ event_route[presence:notify-reply] } if(@cfg_get.kazoo.presence_notify_log_to_table == 1) { - $var(Query) = $_s(REPLACE active_watchers_log SET sent_msg="$(mb{s.escape.common}{s.replace,\','}{s.replace,$$,})", received_msg="$(notify_reply($mb){s.escape.common}{s.replace,\','}{s.replace,$$,})", time=$TS, result=$notify_reply($rs), user_agent="$(subs(user_agent){s.escape.common}{s.replace,\','}{s.replace,$$,})", callid="$subs(callid)", to_user="$subs(to_user)", to_domain="$subs(to_domain)" where presentity_uri="$subs(uri)" watcher_username="$subs(watcher_username)" and watcher_domain="$subs(watcher_domain)" event="$subs(event)"); - mq_add("presence_last_notity", "$subs(watcher_username)@$subs(watcher_domain)", "$var(Query)"); + $var(Query) = $_s(REPLACE active_watchers_log SET sent_msg="$(mb{s.escape.common}{s.replace,\','}{s.replace,$$,})", received_msg="$(notify_reply($mb){s.escape.common}{s.replace,\','}{s.replace,$$,})", time=$TS, result=$notify_reply($rs), user_agent="$(subs(user_agent){s.escape.common}{s.replace,\','}{s.replace,$$,})", callid="$subs(callid)", to_user="$subs(to_user)", to_domain="$subs(to_domain)" where presentity_uri="$subs(uri)" and watcher_username="$subs(watcher_username)" and watcher_domain="$subs(watcher_domain)" and event="$subs(event)"); + mq_add("presence_last_notity", "$subs(callid)", "$var(Query)"); } } @@ -102,13 +102,21 @@ route[PRESENCE_LOG_TIMER_ROUTE] { $var(runloop) = 1; while(mq_fetch("presence_last_notity") == 1 && $var(runloop) < MAX_WHILE_LOOPS) { -# xlog("L_INFO", "Query : $mqv(presence_last_notity)"); - if (sql_query("cb", "$mqv(presence_last_notity)") != 1) { - xlog("L_ERROR", "$ci|log|error updating active_watchers_log\n"); + $var(ci) = $mqk(presence_last_notity); + xlog("L_DEBUG", "Query : $mqv(presence_last_notity)"); + $var(sqlres) = sql_query("cb", "$mqv(presence_last_notity)"); + xlog("L_DEBUG", "Query result : $var(sqlres)"); + if($var(sqlres) < 0) { + xlog("L_ERROR", "$var(ci)|log|error updating active_watchers_log\n"); + } else { + $var(nrows) = $sqlrows(cb); + xlog("L_DEBUG", "$var(ci)|log|end UPDATED $var(nrows)\n"); + if($var(nrows) == 0) { + xlog("L_ERROR", "$var(ci)|log|error no rows affected when updating active_watchers_log\n"); + } } $var(runloop) = $var(runloop) + 1; } - } route[PRESENCE_NOTIFY_AMQP]