[asterisk-commits] jrose: branch 12 r402001 - in /branches/12: res/ res/ari/ rest-api/api-docs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 25 16:53:41 CDT 2013


Author: jrose
Date: Fri Oct 25 16:53:31 2013
New Revision: 402001

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402001
Log:
ARI: channel/bridge recording errors when invalid format specified

Asterisk will now issue 422 if recording is requested against channels
or bridges with an unknown format

(closes issue ASTERISK-22626)
Reported by: Joshua Colp
Review: https://reviewboard.asterisk.org/r/2939/

Modified:
    branches/12/res/ari/resource_bridges.c
    branches/12/res/ari/resource_channels.c
    branches/12/res/res_ari_bridges.c
    branches/12/res/res_ari_channels.c
    branches/12/rest-api/api-docs/bridges.json
    branches/12/rest-api/api-docs/channels.json

Modified: branches/12/res/ari/resource_bridges.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/ari/resource_bridges.c?view=diff&rev=402001&r1=402000&r2=402001
==============================================================================
--- branches/12/res/ari/resource_bridges.c (original)
+++ branches/12/res/ari/resource_bridges.c Fri Oct 25 16:53:31 2013
@@ -438,6 +438,27 @@
 	options->if_exists =
 		stasis_app_recording_if_exists_parse(args->if_exists);
 	options->beep = args->beep;
+
+	if (options->terminate_on == STASIS_APP_RECORDING_TERMINATE_INVALID) {
+		ast_ari_response_error(
+			response, 400, "Bad Request",
+			"terminateOn invalid");
+		return;
+	}
+
+	if (options->if_exists == -1) {
+		ast_ari_response_error(
+			response, 400, "Bad Request",
+			"ifExists invalid");
+		return;
+	}
+
+	if (!ast_get_format_for_file_ext(options->format)) {
+		ast_ari_response_error(
+			response, 422, "Unprocessable Entity",
+			"specified format is unknown on this system");
+		return;
+	}
 
 	recording = stasis_app_control_record(control, options);
 	if (recording == NULL) {

Modified: branches/12/res/ari/resource_channels.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/ari/resource_channels.c?view=diff&rev=402001&r1=402000&r2=402001
==============================================================================
--- branches/12/res/ari/resource_channels.c (original)
+++ branches/12/res/ari/resource_channels.c Fri Oct 25 16:53:31 2013
@@ -404,6 +404,13 @@
 		ast_ari_response_error(
 			response, 400, "Bad Request",
 			"ifExists invalid");
+		return;
+	}
+
+	if (!ast_get_format_for_file_ext(options->format)) {
+		ast_ari_response_error(
+			response, 422, "Unprocessable Entity",
+			"specified format is unknown on this system");
 		return;
 	}
 

Modified: branches/12/res/res_ari_bridges.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_ari_bridges.c?view=diff&rev=402001&r1=402000&r2=402001
==============================================================================
--- branches/12/res/res_ari_bridges.c (original)
+++ branches/12/res/res_ari_bridges.c Fri Oct 25 16:53:31 2013
@@ -745,6 +745,7 @@
 	case 400: /* Invalid parameters */
 	case 404: /* Bridge not found */
 	case 409: /* Bridge is not in a Stasis application; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
+	case 422: /* The format specified is unknown on this system */
 		is_valid = 1;
 		break;
 	default:

Modified: branches/12/res/res_ari_channels.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_ari_channels.c?view=diff&rev=402001&r1=402000&r2=402001
==============================================================================
--- branches/12/res/res_ari_channels.c (original)
+++ branches/12/res/res_ari_channels.c Fri Oct 25 16:53:31 2013
@@ -993,6 +993,7 @@
 	case 400: /* Invalid parameters */
 	case 404: /* Channel not found */
 	case 409: /* Channel is not in a Stasis application; the channel is currently bridged with other hcannels; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail */
+	case 422: /* The format specified is unknown on this system */
 		is_valid = 1;
 		break;
 	default:

Modified: branches/12/rest-api/api-docs/bridges.json
URL: http://svnview.digium.com/svn/asterisk/branches/12/rest-api/api-docs/bridges.json?view=diff&rev=402001&r1=402000&r2=402001
==============================================================================
--- branches/12/rest-api/api-docs/bridges.json (original)
+++ branches/12/rest-api/api-docs/bridges.json Fri Oct 25 16:53:31 2013
@@ -466,7 +466,11 @@
                         {
                             "code": 409,
                             "reason": "Bridge is not in a Stasis application; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail"
-                        }
+                        },
+						{
+							"code": 422,
+							"reason": "The format specified is unknown on this system"
+						}
                     ]
 				}
 			]

Modified: branches/12/rest-api/api-docs/channels.json
URL: http://svnview.digium.com/svn/asterisk/branches/12/rest-api/api-docs/channels.json?view=diff&rev=402001&r1=402000&r2=402001
==============================================================================
--- branches/12/rest-api/api-docs/channels.json (original)
+++ branches/12/rest-api/api-docs/channels.json Fri Oct 25 16:53:31 2013
@@ -721,6 +721,10 @@
 						{
 							"code": 409,
 							"reason": "Channel is not in a Stasis application; the channel is currently bridged with other hcannels; A recording with the same name already exists on the system and can not be overwritten because it is in progress or ifExists=fail"
+						},
+						{
+							"code": 422,
+							"reason": "The format specified is unknown on this system"
 						}
 					]
 				}




More information about the asterisk-commits mailing list