]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
ARI: channel/bridge recording errors when invalid format specified
authorJonathan Rose <jrose@digium.com>
Fri, 25 Oct 2013 21:53:31 +0000 (21:53 +0000)
committerJonathan Rose <jrose@digium.com>
Fri, 25 Oct 2013 21:53:31 +0000 (21:53 +0000)
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/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@402001 65c4cc65-6c06-0410-ace0-fbb531ad65f3

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

index a036ce0f3b6d14f32fe7f7e02710d23a98d7aec7..919171139d29de4a731983ff8ed1a9bd16d0fa4b 100644 (file)
@@ -439,6 +439,27 @@ void ast_ari_record_bridge(struct ast_variable *headers, struct ast_record_bridg
                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) {
                switch(errno) {
index b8d59d38b155756526e7de150d818f13a95ab6bf..f1a9217afbb6b951b2edd39a9522d38150e94421 100644 (file)
@@ -407,6 +407,13 @@ void ast_ari_record_channel(struct ast_variable *headers,
                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) {
                switch(errno) {
index f6a3c1c1a7ec3dfcb73c440d67153ac0072e4548..d34505e2b015177a1636e70fbef01a0d7e512e1b 100644 (file)
@@ -745,6 +745,7 @@ static void ast_ari_record_bridge_cb(
        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:
index 8ff4c065c5d149179973d548e5e3688b3cdc166a..79aa88492ebe442ef50f9f3736c259e04a2dba8f 100644 (file)
@@ -993,6 +993,7 @@ static void ast_ari_record_channel_cb(
        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:
index 187522826a4fd4a21eab1cb5a30327f0a85ba1c9..3174eaaa37bcbb312444bdb50783b19bf9e4573d 100644 (file)
                         {
                             "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"
+                                               }
                     ]
                                }
                        ]
index a9b55873a55f55719cbf537d0b8174fca1c46d9f..39dc4e376afe5c15c7878ad6316da4630cbde822 100644 (file)
                                                {
                                                        "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"
                                                }
                                        ]
                                }