Because I use pua_usrloc I want to apply pua_set_publish() in a REGISTER only if the user wasn't already registered (in order to avoid new NOTIFY with just "online" which can substitute the user client real state PUBLISH).
So I need a function to determine if the user is registered. I can't use: if ( ! lookup("location") { ... because that function checks the URI in "location" table, and in a REGISTER message the URI is just: sip:server
So I need a function to check if the "To:" field ($tu) is registered. Is that exist? or should I make a custom avp_query and so?
Thanks.
El Thursday 09 August 2007 17:21:52 Iñaki Baz Castillo escribió:
Because I use pua_usrloc I want to apply pua_set_publish() in a REGISTER only if the user wasn't already registered (in order to avoid new NOTIFY with just "online" which can substitute the user client real state PUBLISH).
So I need a function to determine if the user is registered. I can't use: if ( ! lookup("location") { ... because that function checks the URI in "location" table, and in a REGISTER message the URI is just: sip:server
So I need a function to check if the "To:" field ($tu) is registered. Is that exist? or should I make a custom avp_query and so?
As I said, I acn implement this feature with a SQL query as I've done:
avp_db_query("select username,domain from location where username='$tU' AND domain='$td'"); if ($rc == -1) { # User not already registered. pua_set_publish(); }
but this jsut works fine with: modparam("usrloc", "db_mode", 1) and not with: modparam("usrloc", "db_mode", 2)
# Database mode: ## 0 = no database ## 1 = immediately write-through ## 2 = periodically write-back ## 3 = DB-only
That's because I was looking for a way to test if a user is registered or not by testing the To field ($rU) of the REGISTER message.
Thanks for any help. modparam("usrloc", "db_mode", 2)
Hi,
check the "registered()" function: http://www.openser.org/docs/modules/1.2.x/registrar.html#AEN368
as it checks the RURI, you may need to "play" a bit to make it work for To URI (backup ruri, put to_uri in ruri, run function, restore ruri).
regards, bogdan
Iñaki Baz Castillo wrote:
Because I use pua_usrloc I want to apply pua_set_publish() in a REGISTER only if the user wasn't already registered (in order to avoid new NOTIFY with just "online" which can substitute the user client real state PUBLISH).
So I need a function to determine if the user is registered. I can't use: if ( ! lookup("location") { ... because that function checks the URI in "location" table, and in a REGISTER message the URI is just: sip:server
So I need a function to check if the "To:" field ($tu) is registered. Is that exist? or should I make a custom avp_query and so?
Thanks.
El Friday 10 August 2007 09:07:38 Bogdan-Andrei Iancu escribió:
Hi,
check the "registered()" function: http://www.openser.org/docs/modules/1.2.x/registrar.html#AEN368
as it checks the RURI, you may need to "play" a bit to make it work for To URI (backup ruri, put to_uri in ruri, run function, restore ruri).
Yes, I already was it, but as you say is a bit "dirty".
Anyway, unfortunatelly I've discovered that my "strategy" is not valid since if I jsut create the auto-PUBLICH (pua_usrloc) when the first REGISTER, then after the PUBLISH has expired the contact will always appears as offline (if it doesn't allow PRESENCE).
Thanks for all.