message & stasis/messaging: make text message variables work in ARI

When a text message was received any associated variable was not written to
the ARI TextMessageReceived event. This occurred because Asterisk only wrote
out "send" variables. However, even those "send" variables would fail ARI
validation due to a TextMessageVariable formatting bug.

Since it seems the TextMessageReceived event has never been able to include
actual variables it was decided to remove the TextMessageVariable object type
from ARI, and simply return a JSON object of key/value pairs for variables.
This aligns more with how the ARI sendMessage handles variables, and other
places in ARI.

That being the case, and since this is technically an API breaking change (no
one should really be affected since things never really worked) the ARI version
was updated to reflect that.

ASTERISK-28755 #close

Change-Id: Ia6051c01a53b30cf7edef84c27df4ed4479b8b6f
This commit is contained in:
Kevin Harwell
2020-02-28 12:54:14 -06:00
parent ac95b79699
commit c47dbf1fbe
8 changed files with 66 additions and 109 deletions

View File

@@ -627,7 +627,9 @@ struct ast_msg_var_iterator *ast_msg_var_iterator_init(const struct ast_msg *msg
return iter;
}
int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value)
static int ast_msg_var_iterator_get_next(const struct ast_msg *msg,
struct ast_msg_var_iterator *iter, const char **name, const char **value,
unsigned int send)
{
struct msg_data *data;
@@ -635,8 +637,8 @@ int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iter
return 0;
}
/* Skip any that aren't marked for sending out */
while ((data = ao2_iterator_next(&iter->iter)) && !data->send) {
/* Skip any that we're told to */
while ((data = ao2_iterator_next(&iter->iter)) && (data->send != send)) {
ao2_ref(data, -1);
}
@@ -644,7 +646,7 @@ int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iter
return 0;
}
if (data->send) {
if (data->send == send) {
*name = data->name;
*value = data->value;
}
@@ -656,6 +658,17 @@ int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iter
return 1;
}
int ast_msg_var_iterator_next(const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value)
{
return ast_msg_var_iterator_get_next(msg, iter, name, value, 1);
}
int ast_msg_var_iterator_next_received(const struct ast_msg *msg,
struct ast_msg_var_iterator *iter, const char **name, const char **value)
{
return ast_msg_var_iterator_get_next(msg, iter, name, value, 0);
}
void ast_msg_var_unref_current(struct ast_msg_var_iterator *iter)
{
ao2_cleanup(iter->current_used);