This is my script. I found that for a register, E_UL_CONTACT_INSERT will be triggered one or more times. I don’t want to invite the same client multiple times.
route[route_to_user] {
t_newtran();
t_on_branch("per_branch_ops");
t_on_reply("handle_nat");
t_wait_for_new_branches();
$avp(filter) = "aor="+$rU+"@"+$rd;
notify_on_event("E_UL_CONTACT_INSERT", $avp(filter), "fork_call", 60);
lookup("location");
exit;
}
route[fork_call] {
t_inject_branches("event");
}
These are what i tried:
- According to the document
As an exception, in the notification route, the EBR module will make available the transaction ID from the subscriber context.
In fork_call, I want to use transaction ID and $avp(uri) as the cache key to detect duplicate E_UL_CONTACT_INSERT. But I can't find how to get transaction ID in fork_call.
- Let E_UL_CONTACT_INSERT be triggered only once, but I have no idea here.
Is there a better solution? thanks.
I modified the setting of working_mode_preset to solve this problem.
original:
modified:
When working_mode_preset is sql-only, lookup will trigger E_UL_CONTACT_INSERT, but it will trigger one or more times.
When working_mode_preset is single-instance-sql-write-through, lookup will not trigger E_UL_CONTACT_INSERT, so I have to execute route(relay).
I am not sure if this is a bug, but this solved my problem and I am still looking for the correct answer.