[OpenSER-Users] A function to know if a user is registered?

Iñaki Baz Castillo ibc at in.ilimit.es
Thu Aug 9 17:47:36 CEST 2007


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)


-- 
Iñaki Baz Castillo
ibc at in.ilimit.es




More information about the sr-users mailing list