<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16498">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">message.c: Support 'To' header override with AMI's MessageSend.<br><br>The MessageSend AMI action has been updated to allow the Destination<br>and the To addresses to be provided separately. This brings the<br>MessageSend manager command in line with the capabilities of the<br>MessageSend dialplan application.<br><br>ASTERISK-29663 #close<br><br>Change-Id: I8513168d3e189a9fed88aaab6f5547ccb50d332c<br>---<br>A doc/CHANGES-staging/manager_message_send.txt<br>M main/message.c<br>2 files changed, 39 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/98/16498/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/CHANGES-staging/manager_message_send.txt b/doc/CHANGES-staging/manager_message_send.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..ab5b58a</span><br><span>--- /dev/null</span><br><span>+++ b/doc/CHANGES-staging/manager_message_send.txt</span><br><span>@@ -0,0 +1,6 @@</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: MessageSend</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The MessageSend AMI action has been updated to allow the Destination</span><br><span style="color: hsl(120, 100%, 40%);">+and the To addresses to be provided separately. This brings the</span><br><span style="color: hsl(120, 100%, 40%);">+MessageSend manager command in line with the capabilities of the</span><br><span style="color: hsl(120, 100%, 40%);">+MessageSend dialplan application.</span><br><span>diff --git a/main/message.c b/main/message.c</span><br><span>index 75450e9..8ca3987 100644</span><br><span>--- a/main/message.c</span><br><span>+++ b/main/message.c</span><br><span>@@ -190,8 +190,22 @@</span><br><span> </synopsis></span><br><span> <syntax></span><br><span> <xi:include xpointer="xpointer(/docs/manager[@name='Login']/syntax/parameter[@name='ActionID'])" /></span><br><span style="color: hsl(0, 100%, 40%);">- <parameter name="To" required="true"></span><br><span style="color: hsl(0, 100%, 40%);">- <para>The URI the message is to be sent to.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="Destination" required="false"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>A To URI for the message. If Destination is provided, the To</span><br><span style="color: hsl(120, 100%, 40%);">+ parameter can also be supplied and may alter the message based on</span><br><span style="color: hsl(120, 100%, 40%);">+ the specified message technology.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>For backwards compatibility, if Destination is not provided,</span><br><span style="color: hsl(120, 100%, 40%);">+ the To parameter must be provided and will be used as the message</span><br><span style="color: hsl(120, 100%, 40%);">+ destination.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <xi:include xpointer="xpointer(/docs/info[@name='MessageDestinationInfo'])" /></span><br><span style="color: hsl(120, 100%, 40%);">+ </parameter></span><br><span style="color: hsl(120, 100%, 40%);">+ <parameter name="To" required="false"></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>A To URI for the message if needed for the</span><br><span style="color: hsl(120, 100%, 40%);">+ message technology being used to send this message. This can be a</span><br><span style="color: hsl(120, 100%, 40%);">+ SIP(S) URI, such as <literal>Alice <sip:alice@atlanta.com></literal>,</span><br><span style="color: hsl(120, 100%, 40%);">+ or a string in the format <literal>alice@atlanta.com</literal>.</para></span><br><span style="color: hsl(120, 100%, 40%);">+ <para>This parameter is required if the Destination parameter is not</span><br><span style="color: hsl(120, 100%, 40%);">+ provided.</para></span><br><span> <xi:include xpointer="xpointer(/docs/info[@name='MessageToInfo'])" /></span><br><span> </parameter></span><br><span> <parameter name="From"></span><br><span>@@ -1305,10 +1319,12 @@</span><br><span> </span><br><span> static int action_messagesend(struct mansession *s, const struct message *m)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *to = ast_strdupa(astman_get_header(m, "To"));</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *destination = astman_get_header(m, "Destination");</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *to = astman_get_header(m, "To");</span><br><span> const char *from = astman_get_header(m, "From");</span><br><span> const char *body = astman_get_header(m, "Body");</span><br><span> const char *base64body = astman_get_header(m, "Base64Body");</span><br><span style="color: hsl(120, 100%, 40%);">+ const char *to_override = NULL;</span><br><span> char base64decoded[1301] = { 0, };</span><br><span> char *tech_name = NULL;</span><br><span> struct ast_variable *vars = NULL;</span><br><span>@@ -1317,9 +1333,16 @@</span><br><span> struct ast_msg *msg;</span><br><span> int res = -1;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_strlen_zero(to)) {</span><br><span style="color: hsl(0, 100%, 40%);">- astman_send_error(s, m, "No 'To' address specified.");</span><br><span style="color: hsl(0, 100%, 40%);">- return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(destination)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (!ast_strlen_zero(to)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ to_override = to;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ to = destination;</span><br><span style="color: hsl(120, 100%, 40%);">+ } else {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (ast_strlen_zero(to)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ astman_send_error(s, m, "No 'To' address specified.");</span><br><span style="color: hsl(120, 100%, 40%);">+ return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> if (!ast_strlen_zero(base64body)) {</span><br><span>@@ -1351,6 +1374,10 @@</span><br><span> </span><br><span> ast_msg_set_body(msg, "%s", body);</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if (to_override) {</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_string_field_set(msg, to, to_override);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> res = msg_tech->msg_send(msg, S_OR(to, ""), S_OR(from, ""));</span><br><span> </span><br><span> ast_rwlock_unlock(&msg_techs_lock);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16498">change 16498</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/16498"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I8513168d3e189a9fed88aaab6f5547ccb50d332c </div>
<div style="display:none"> Gerrit-Change-Number: 16498 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>