Hi Alexandru,
The Expire header in Register can be your clue here. if it is greater than 0 means its a registration attempt. If the value is 0 then it is un-register request.
This is how you can catch this.
if(is_method("REGISTER") ) {
if($hdr(Expire) == 0) {
// Un-Registering User $fU
} else {
// Register request
}
}
I'd say put it somewhere just before the save("lcoation"); line.
The event for contact-expired will work for a user when its expires timer exceeds and there is no registration refresh from the device and hence Kamailio removes the contact from usrloc records.
Regards,
Sammy