]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
stasis_channels.c: Make protocol_id optional to enable blind transfer via ari
authorSven Kube <mail@sven-kube.de>
Mon, 22 Sep 2025 06:00:44 +0000 (08:00 +0200)
committerSven Kube <mail@sven-kube.de>
Tue, 23 Sep 2025 19:49:56 +0000 (19:49 +0000)
When handling SIP transfers via ARI, there is no protocol_id in case of
a blind transfer.

Resolves: #1467

main/stasis_channels.c

index 76173aa35212cd614592bfba0c5aa8177be16046..4e74733935e5d128f9bf2b85934d7a1a24749a06 100644 (file)
@@ -1666,13 +1666,16 @@ static struct ast_json *ari_transfer_to_json(struct stasis_message *msg,
        const struct timeval *tv = stasis_message_timestamp(msg);
        struct ast_ari_transfer_message *transfer_msg = stasis_message_data(msg);
 
-       dest_json = ast_json_pack("{s: s, s: s}",
-               "protocol_id", transfer_msg->protocol_id,
-               "destination", transfer_msg->destination);
+       dest_json = ast_json_pack("{s: s}", "destination", transfer_msg->destination);
        if (!dest_json) {
                return NULL;
        }
 
+       if (transfer_msg->protocol_id) {
+               ast_json_object_set(dest_json, "protocol_id",
+                       ast_json_string_create(transfer_msg->protocol_id));
+       }
+
        if (AST_VECTOR_SIZE(transfer_msg->refer_params) > 0) {
                struct ast_json *params = ast_json_array_create();
                if (!params) {
@@ -1806,10 +1809,13 @@ struct ast_ari_transfer_message *ast_ari_transfer_message_create(struct ast_chan
        }
 
        ast_copy_string(msg->destination, exten, sizeof(msg->destination));
-       msg->protocol_id = ast_strdup(protocol_id);
-       if (!msg->protocol_id) {
-               ao2_cleanup(msg);
-               return NULL;
+
+       if (protocol_id) {
+               msg->protocol_id = ast_strdup(protocol_id);
+               if (!msg->protocol_id) {
+                       ao2_cleanup(msg);
+                       return NULL;
+               }
        }
 
        return msg;