mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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:
@@ -262,23 +262,20 @@ static struct ast_json *msg_to_json(struct ast_msg *msg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_vars = ast_json_array_create();
|
||||
json_vars = ast_json_object_create();
|
||||
if (!json_vars) {
|
||||
ast_msg_var_iterator_destroy(it_vars);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (ast_msg_var_iterator_next(msg, it_vars, &name, &value)) {
|
||||
struct ast_json *json_tuple;
|
||||
|
||||
json_tuple = ast_json_pack("{s: s}", name, value);
|
||||
if (!json_tuple) {
|
||||
while (ast_msg_var_iterator_next_received(msg, it_vars, &name, &value)) {
|
||||
struct ast_json *json_val = ast_json_string_create(value);
|
||||
if (!json_val || ast_json_object_set(json_vars, name, json_val)) {
|
||||
ast_json_unref(json_vars);
|
||||
ast_msg_var_iterator_destroy(it_vars);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ast_json_array_append(json_vars, json_tuple);
|
||||
ast_msg_var_unref_current(it_vars);
|
||||
}
|
||||
ast_msg_var_iterator_destroy(it_vars);
|
||||
|
Reference in New Issue
Block a user