<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Dennis,</p>
<p>Thank you. Becoming more and more nasty by the moment ...<br>
</p>
On 2021/02/24 10:07, Dennis Buteyn wrote:<br>
<blockquote type="cite"
cite="mid:556989e8-1822-2c63-a04f-f537738dbee9@xorcom.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div class="moz-cite-prefix">On 2/24/21 1:01 AM, Jaco Kroon wrote:<br>
</div>
<blockquote type="cite"
cite="mid:f82aed56-60b7-0f28-b0d0-25032bc10295@uls.co.za">
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<p>Hi,</p>
<p>I still think the changes for forcecommit should be done for
func_odbc, however, after various discussions we've decided to
give the daemon route a shot.<br>
</p>
<p>So just looking at the raw AMI event via UserEvent, this
seems to have a problem with quoting, for example:<br>
<br>
Set(ODBC_trace()=CallerID: ${CALLERID(all)})<br>
UserEvent(trace,Message: CallerID: ${CALLERID(all)})<br>
<br>
The former in the DB ends up as: CallerID: "name"
<number><br>
</p>
<p>The quotes are missing in the AMI event:</p>
<p>Message: CallerID name <number><br>
</p>
<p>Is this a bug, or am I missing some escaping that needs to
happen prior to passing to UserEvent?</p>
<p>Kind Regards,<br>
Jaco<br>
</p>
</blockquote>
<p>Interesting, I couldn't find anyone having similar problems nor
any working examples. I tried <tt><i>UserEvent(trace,Message:
CallerID: ${QUOTE(${CALLERID(all)})})</i></tt> but that
becomes <i><tt>AppData: trace, CallerID: "\"2000\"
<2000>"</tt></i>. I guess UserEvent() is having a bad
day. While trying to encode the body as JSON (which also doesn't
work) I did find the workaround below which I think is pretty
close:</p>
<p><tt>UserEvent(trace,CallerID:{${QUOTE(${CALLERID(all)})}},Val:{${QUOTE("quoted")}})</tt></p>
<p><tt>Event: UserEvent</tt><tt><br>
</tt><tt>Privilege: user,all</tt><tt><br>
</tt><tt>Channel: SIP/2000-00000016</tt><tt><br>
</tt><tt>ChannelState: 6</tt><tt><br>
</tt><tt>ChannelStateDesc: Up</tt><tt><br>
</tt><tt>CallerIDNum: 2000</tt><tt><br>
</tt><tt>CallerIDName: 2000</tt><tt><br>
</tt><tt>ConnectedLineNum: <unknown></tt><tt><br>
</tt><tt>ConnectedLineName: <unknown></tt><tt><br>
</tt><tt>Language: en</tt><tt><br>
</tt><tt>AccountCode: </tt><tt><br>
</tt><tt>Context: sub-speakextennum</tt><tt><br>
</tt><tt>Exten: s</tt><tt><br>
</tt><tt>Priority: 3</tt><tt><br>
</tt><tt>Uniqueid: 1614152491.107</tt><tt><br>
</tt><tt>Linkedid: 1614152491.107</tt><tt><br>
</tt><tt>UserEvent: trace</tt><tt><br>
</tt><tt>CallerID: {"2000" <2000>}</tt><tt><br>
</tt><tt>Val: {"quoted"}</tt><br>
<br>
</p>
<p>In any case, the UserEvent itself already contains the CID
(CallerIDNum, CallerIDName) but I assume you were testing
quoting behavior.<br>
</p>
</blockquote>
<p>Stripped down version of what we have, plus keep in mind
ODBC_trace() logs *arbitrary* messages, so yes, things like
certain SIP headers aren't passed by default.<br>
</p>
<blockquote type="cite"
cite="mid:556989e8-1822-2c63-a04f-f537738dbee9@xorcom.com">
<p> </p>
<p>There is also the alternative of listening to VarSet events. It
is much more spammy but is more straight-forward in dialplan and
works with arrays:<br>
</p>
</blockquote>
<p>Nasty. Basically I could then do a simple Set(trace=message here
...) but as you say, I'd need to listen in on ALL VarSet events,
and those are indeed many. Especially when listening on on 100+
asterisk instances, or on a busy host (with 5-10 new INVITEs/s
which I seriously doubt is anywhere near the busiest hosts in the
world, but busy enough).<br>
</p>
<blockquote type="cite"
cite="mid:556989e8-1822-2c63-a04f-f537738dbee9@xorcom.com">
<p>Another alternative would be to format the event per your own
preferences:</p>
<p><tt>UserEvent(CallerID=${QUOTE(${CALLERID(all)})}|Val=${QUOTE("quoted")})</tt></p>
<p><tt>Event: UserEvent</tt><tt><br>
</tt><tt>...</tt><tt><br>
</tt><tt>UserEvent: CallerID="2000" <2000>|Val="quoted"</tt><br>
</p>
</blockquote>
<p>Interesting idea, yes, that may be an idea. However, this seems
to give the exact right results:</p>
<p><tt>UserEvent(trace,Level: user,Message:
${QUOTE(${CALLERID(all)})})</tt></p>
<p>UserEvent can then absorb the outermost quotes that ${QUOTE()}
adds, and \" ends up going through correctly.</p>
<p>I've tried messages containing , in this configuration too, and
it seems to work correctly. On the daemon side I can the default
the Level: if not specified.<br>
<br>
Set(ODBC_trace(level)=Message goes here with ${VARS})</p>
<p>Still feels a lot cleaner to me compared to:<br>
<br>
UserEvent(trace,Level: level,Message:${QUOTE(Message goes here
with ${VARS})})<br>
<br>
At least the conversion is now very much awk/sed'able.</p>
<p>POC daemon on AMI side didn't take too long to cook up either,
thank you for the suggestion.</p>
<p>May still consider making the forcecommit and async commit
changes (With forcecommit you lose the error reporting anyway, so
making that async, even by default, IMHO is acceptable). Might
not need it right now, but IMHO it's still the right thing to do.</p>
<p>Thanks again.</p>
<p>Kind Regards,<br>
Jaco</p>
</body>
</html>