[Asterisk-code-review] resource_channels.c: Fix wrong external media parameter parse (asterisk[16])

Friendly Automation asteriskteam at digium.com
Thu Sep 2 15:09:53 CDT 2021


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/16432 )

Change subject: resource_channels.c: Fix wrong external media parameter parse
......................................................................

resource_channels.c: Fix wrong external media parameter parse

Fixed ARI external media handler to accept body parameters.

ASTERISK-29622

Change-Id: I49509c48a6cbc0fb4165bfa4f834b5e8b9ace20d
---
M res/ari/resource_channels.c
1 file changed, 12 insertions(+), 11 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, approved
  George Joseph: Looks good to me, but someone else must approve
  Friendly Automation: Approved for Submit



diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index 8b7cf96..4854dca 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -2134,6 +2134,18 @@
 
 	ast_assert(response != NULL);
 
+	/* Parse any query parameters out of the body parameter */
+	if (args->variables) {
+		struct ast_json *json_variables;
+
+		ast_ari_channels_external_media_parse_body(args->variables, args);
+		json_variables = ast_json_object_get(args->variables, "variables");
+		if (json_variables
+			&& json_to_ast_variables(response, json_variables, &variables)) {
+			return;
+		}
+	}
+
 	if (ast_strlen_zero(args->app)) {
 		ast_ari_response_error(response, 400, "Bad Request", "app cannot be empty");
 		return;
@@ -2168,17 +2180,6 @@
 		args->direction = "both";
 	}
 
-	if (args->variables) {
-		struct ast_json *json_variables;
-
-		ast_ari_channels_external_media_parse_body(args->variables, args);
-		json_variables = ast_json_object_get(args->variables, "variables");
-		if (json_variables
-			&& json_to_ast_variables(response, json_variables, &variables)) {
-			return;
-		}
-	}
-
 	if (strcasecmp(args->encapsulation, "rtp") == 0 && strcasecmp(args->transport, "udp") == 0) {
 		external_media_rtp_udp(args, variables, response);
 	} else {

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/16432
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I49509c48a6cbc0fb4165bfa4f834b5e8b9ace20d
Gerrit-Change-Number: 16432
Gerrit-PatchSet: 2
Gerrit-Owner: Sungtae Kim <pchero21 at gmail.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210902/ccfb28e7/attachment.html>


More information about the asterisk-code-review mailing list