]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
ARI: Add duplicate channel ID checking for channel creation. 58/4158/4
authorMark Michelson <mmichelson@digium.com>
Wed, 19 Oct 2016 17:05:28 +0000 (12:05 -0500)
committerMark Michelson <mmichelson@digium.com>
Thu, 20 Oct 2016 18:00:24 +0000 (13:00 -0500)
This is similar to what is done for origination, but for the 14 and up
channel creation method. When attempting to create a channel, if a
channel ID is specified and a channel already exists with that ID, then
a 409 is returned.

Change-Id: I77f9253278c6947939c418073b6b31065489187c

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

index 89c9d7f8440070bcafd43903f71abe2fc1592bdc..dfd9bc66bc008e68c550e7a09ecc67dc68e59858 100644 (file)
@@ -1826,7 +1826,12 @@ void ast_ari_channels_create(struct ast_variable *headers,
        ao2_cleanup(request_cap);
 
        if (!chan_data->chan) {
-               ast_ari_response_alloc_failed(response);
+               if (ast_channel_errno() == AST_CHANNEL_ERROR_ID_EXISTS) {
+                       ast_ari_response_error(response, 409, "Conflict",
+                               "Channel with given unique ID already exists");
+               } else {
+                       ast_ari_response_alloc_failed(response);
+               }
                ast_channel_cleanup(originator);
                chan_data_destroy(chan_data);
                return;
index b7c088c4d1a9ba2ecbd8d7d94c7b835d7daa15c9..9e8eeb4e901b359f7768d2f78091394f760028fa 100644 (file)
@@ -386,6 +386,7 @@ static void ast_ari_channels_create_cb(
                break;
        case 500: /* Internal Server Error */
        case 501: /* Not Implemented */
+       case 409: /* Channel with given unique ID already exists. */
                is_valid = 1;
                break;
        default:
index 522cc00c4928b7a8b60367a474773ee045e9eeb0..e707c068f542eb5a9d718ed8de97e3aee638b352 100644 (file)
                                                        "allowMultiple": false,
                                                        "dataType": "string"
                                                }
+                                       ],
+                                       "errorResponses": [
+                                               {
+                                                       "code": 409,
+                                                       "reason": "Channel with given unique ID already exists."
+                                               }
                                        ]
                                }
                        ]