<div dir="auto">Beware that since you’re removing all contacts, if any are valid and if any of the contacts that did not unregister is called, Kamailio won’t find them.</div><div dir="auto"><br></div><div dir="auto">If what you need is not force only one contact per user, maybe look at </div><div dir="auto"><div><a href="http://www.kamailio.net/docs/modules/5.4.x/modules/registrar.html#registrar.f.save">http://www.kamailio.net/docs/modules/5.4.x/modules/registrar.html#registrar.f.save</a></div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 21 Feb 2021 at 13:14, Charles Phillips <<a href="mailto:charles@rustybike.com">charles@rustybike.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div style="word-wrap:break-word;line-break:after-white-space">Sorted it.  I needed to loop through the contacts, then select the correct ruid based on $ci<div><br></div><div>For completeness, here is my solution:</div><div><br></div>reg_fetch_contacts("location", "$fu", "un_reg");<br>    $var(i) = 0;<br>    while ($var(i) < $(ulc(un_reg=>count))) {<br>        $var(ul_callid) = $(ulc(un_reg=>callid)[$var(i)]);<br>        $var(ul_ruid) = $(ulc(un_reg=>ruid)[$var(i)]);<br>        if ($var(ul_callid) == $ci) {<br>            xlog("L_INFO", "Unregistering contact $tu Ruid: $var(ul_ruid)\n");<br>            unregister("location", "$fu", "$var(ul_ruid)");<br>            $sht(regs=>$fU@$fd~$ci)=$null;<br>        }<br>        $var(i) = $var(i) + 1;<br><div>    } </div></div><div style="word-wrap:break-word;line-break:after-white-space"><div><br><div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word;color:rgb(0,0,0)"><div style="font-family:Helvetica"><br>- Charles </div><div style="font-family:Helvetica"><br></div></div><br style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>

</div>
<div><br><blockquote type="cite"><div>On Feb 19, 2021, at 9:43 AM, Charles Phillips <<a href="mailto:charles@rustybike.com" target="_blank">charles@rustybike.com</a>> wrote:</div><br><div><div style="word-wrap:break-word;line-break:after-white-space">Happy Friday!<br><div><br></div><div>To clean up contacts that have sent requests to unregister (Expires: 0) I am executing the following after a 200 OK response from the upstream server:<div><br></div><div>    reg_fetch_contacts("location", "$fu", "un_reg");<br>    xlog("L_INFO", "Removing unregistered contact From: $si To: $tu Ruid: $ulc(un_reg=>ruid)\n");<br>    unregister("location", "$fu", "$ulc(un_reg=>ruid)”);</div><div><br></div><div>This produces the desired result when there is only one contact per AoR, but when multiple contacts are present, it seems to delete the first ruid (which makes sense as I am only providing the $fu).  </div><div><br></div><div>So, the question, can I select the contact by call-id or some other unique identifier specific to the desired contact that I can grab from the transaction?  Reading the reg_fetch_contact and unregister docs, they do not seem to provide for selection beyond uri.</div><div><br></div><div><div>
<div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word;line-break:after-white-space"><div style="font-family:Helvetica"><br>- Charles</div><div style="font-family:Helvetica"><br></div></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br>

</div>

<br></div></div></div></div></blockquote></div><br></div></div>_______________________________________________<br>
Kamailio (SER) - Users Mailing List<br>
<a href="mailto:sr-users@lists.kamailio.org" target="_blank">sr-users@lists.kamailio.org</a><br>
<a href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Regards,</div><div><br></div>David Villasmil<div>email: <a href="mailto:david.villasmil.work@gmail.com" target="_blank">david.villasmil.work@gmail.com</a></div><div>phone: +34669448337</div></div></div>