mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-23 13:09:00 +00:00
res_stasis: Enable transfers and provide events when they occur.
This change enables transfers within ARI created bridges and adds events for when they occur. Unlike other events these will be received if *any* subscribed object is involved in the transfer. (closes issue ASTERISK-22984) Reported by: David M. Lee Review: https://reviewboard.asterisk.org/r/3120/ ........ Merged revisions 407153 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407154 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1552,6 +1552,373 @@ ari_validator ast_ari_validate_application_replaced_fn(void)
|
||||
return ast_ari_validate_application_replaced;
|
||||
}
|
||||
|
||||
int ast_ari_validate_bridge_attended_transfer(struct ast_json *json)
|
||||
{
|
||||
int res = 1;
|
||||
struct ast_json_iter *iter;
|
||||
int has_type = 0;
|
||||
int has_application = 0;
|
||||
int has_destination_type = 0;
|
||||
int has_is_external = 0;
|
||||
int has_result = 0;
|
||||
int has_transferer_first_leg = 0;
|
||||
int has_transferer_second_leg = 0;
|
||||
|
||||
for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
|
||||
if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_type = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field type failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_application = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field application failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_date(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field timestamp failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("destination_application", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_application failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("destination_bridge", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_bridge failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("destination_link_first_leg", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_channel(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_first_leg failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("destination_link_second_leg", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_channel(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_link_second_leg failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("destination_threeway_bridge", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_bridge(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_bridge failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("destination_threeway_channel", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_channel(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_threeway_channel failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("destination_type", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_destination_type = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field destination_type failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_is_external = 1;
|
||||
prop_is_valid = ast_ari_validate_boolean(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field is_external failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_result = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field result failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("transferer_first_leg", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_transferer_first_leg = 1;
|
||||
prop_is_valid = ast_ari_validate_channel(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("transferer_first_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_bridge(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_first_leg_bridge failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("transferer_second_leg", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_transferer_second_leg = 1;
|
||||
prop_is_valid = ast_ari_validate_channel(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("transferer_second_leg_bridge", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_bridge(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer field transferer_second_leg_bridge failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
ast_log(LOG_ERROR,
|
||||
"ARI BridgeAttendedTransfer has undocumented field %s\n",
|
||||
ast_json_object_iter_key(iter));
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_type) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field type\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_application) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field application\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_destination_type) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field destination_type\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_is_external) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field is_external\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_result) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field result\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_transferer_first_leg) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_first_leg\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_transferer_second_leg) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeAttendedTransfer missing required field transferer_second_leg\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ari_validator ast_ari_validate_bridge_attended_transfer_fn(void)
|
||||
{
|
||||
return ast_ari_validate_bridge_attended_transfer;
|
||||
}
|
||||
|
||||
int ast_ari_validate_bridge_blind_transfer(struct ast_json *json)
|
||||
{
|
||||
int res = 1;
|
||||
struct ast_json_iter *iter;
|
||||
int has_type = 0;
|
||||
int has_application = 0;
|
||||
int has_channel = 0;
|
||||
int has_context = 0;
|
||||
int has_exten = 0;
|
||||
int has_is_external = 0;
|
||||
int has_result = 0;
|
||||
|
||||
for (iter = ast_json_object_iter(json); iter; iter = ast_json_object_iter_next(json, iter)) {
|
||||
if (strcmp("type", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_type = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field type failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("application", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_application = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field application failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("timestamp", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_date(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field timestamp failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("bridge", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
prop_is_valid = ast_ari_validate_bridge(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field bridge failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("channel", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_channel = 1;
|
||||
prop_is_valid = ast_ari_validate_channel(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field channel failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("context", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_context = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field context failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("exten", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_exten = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field exten failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("is_external", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_is_external = 1;
|
||||
prop_is_valid = ast_ari_validate_boolean(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field is_external failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
if (strcmp("result", ast_json_object_iter_key(iter)) == 0) {
|
||||
int prop_is_valid;
|
||||
has_result = 1;
|
||||
prop_is_valid = ast_ari_validate_string(
|
||||
ast_json_object_iter_value(iter));
|
||||
if (!prop_is_valid) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer field result failed validation\n");
|
||||
res = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
ast_log(LOG_ERROR,
|
||||
"ARI BridgeBlindTransfer has undocumented field %s\n",
|
||||
ast_json_object_iter_key(iter));
|
||||
res = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_type) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field type\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_application) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field application\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_channel) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field channel\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_context) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field context\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_exten) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field exten\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_is_external) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field is_external\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
if (!has_result) {
|
||||
ast_log(LOG_ERROR, "ARI BridgeBlindTransfer missing required field result\n");
|
||||
res = 0;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ari_validator ast_ari_validate_bridge_blind_transfer_fn(void)
|
||||
{
|
||||
return ast_ari_validate_bridge_blind_transfer;
|
||||
}
|
||||
|
||||
int ast_ari_validate_bridge_created(struct ast_json *json)
|
||||
{
|
||||
int res = 1;
|
||||
@@ -3211,6 +3578,12 @@ int ast_ari_validate_event(struct ast_json *json)
|
||||
if (strcmp("ApplicationReplaced", discriminator) == 0) {
|
||||
return ast_ari_validate_application_replaced(json);
|
||||
} else
|
||||
if (strcmp("BridgeAttendedTransfer", discriminator) == 0) {
|
||||
return ast_ari_validate_bridge_attended_transfer(json);
|
||||
} else
|
||||
if (strcmp("BridgeBlindTransfer", discriminator) == 0) {
|
||||
return ast_ari_validate_bridge_blind_transfer(json);
|
||||
} else
|
||||
if (strcmp("BridgeCreated", discriminator) == 0) {
|
||||
return ast_ari_validate_bridge_created(json);
|
||||
} else
|
||||
@@ -3364,6 +3737,12 @@ int ast_ari_validate_message(struct ast_json *json)
|
||||
if (strcmp("ApplicationReplaced", discriminator) == 0) {
|
||||
return ast_ari_validate_application_replaced(json);
|
||||
} else
|
||||
if (strcmp("BridgeAttendedTransfer", discriminator) == 0) {
|
||||
return ast_ari_validate_bridge_attended_transfer(json);
|
||||
} else
|
||||
if (strcmp("BridgeBlindTransfer", discriminator) == 0) {
|
||||
return ast_ari_validate_bridge_blind_transfer(json);
|
||||
} else
|
||||
if (strcmp("BridgeCreated", discriminator) == 0) {
|
||||
return ast_ari_validate_bridge_created(json);
|
||||
} else
|
||||
|
@@ -536,6 +536,42 @@ int ast_ari_validate_application_replaced(struct ast_json *json);
|
||||
*/
|
||||
ari_validator ast_ari_validate_application_replaced_fn(void);
|
||||
|
||||
/*!
|
||||
* \brief Validator for BridgeAttendedTransfer.
|
||||
*
|
||||
* Notification that an attended transfer has occurred.
|
||||
*
|
||||
* \param json JSON object to validate.
|
||||
* \returns True (non-zero) if valid.
|
||||
* \returns False (zero) if invalid.
|
||||
*/
|
||||
int ast_ari_validate_bridge_attended_transfer(struct ast_json *json);
|
||||
|
||||
/*!
|
||||
* \brief Function pointer to ast_ari_validate_bridge_attended_transfer().
|
||||
*
|
||||
* See \ref ast_ari_model_validators.h for more details.
|
||||
*/
|
||||
ari_validator ast_ari_validate_bridge_attended_transfer_fn(void);
|
||||
|
||||
/*!
|
||||
* \brief Validator for BridgeBlindTransfer.
|
||||
*
|
||||
* Notification that a blind transfer has occurred.
|
||||
*
|
||||
* \param json JSON object to validate.
|
||||
* \returns True (non-zero) if valid.
|
||||
* \returns False (zero) if invalid.
|
||||
*/
|
||||
int ast_ari_validate_bridge_blind_transfer(struct ast_json *json);
|
||||
|
||||
/*!
|
||||
* \brief Function pointer to ast_ari_validate_bridge_blind_transfer().
|
||||
*
|
||||
* See \ref ast_ari_model_validators.h for more details.
|
||||
*/
|
||||
ari_validator ast_ari_validate_bridge_blind_transfer_fn(void);
|
||||
|
||||
/*!
|
||||
* \brief Validator for BridgeCreated.
|
||||
*
|
||||
@@ -1137,6 +1173,33 @@ ari_validator ast_ari_validate_application_fn(void);
|
||||
* - type: string (required)
|
||||
* - application: string (required)
|
||||
* - timestamp: Date
|
||||
* BridgeAttendedTransfer
|
||||
* - type: string (required)
|
||||
* - application: string (required)
|
||||
* - timestamp: Date
|
||||
* - destination_application: string
|
||||
* - destination_bridge: string
|
||||
* - destination_link_first_leg: Channel
|
||||
* - destination_link_second_leg: Channel
|
||||
* - destination_threeway_bridge: Bridge
|
||||
* - destination_threeway_channel: Channel
|
||||
* - destination_type: string (required)
|
||||
* - is_external: boolean (required)
|
||||
* - result: string (required)
|
||||
* - transferer_first_leg: Channel (required)
|
||||
* - transferer_first_leg_bridge: Bridge
|
||||
* - transferer_second_leg: Channel (required)
|
||||
* - transferer_second_leg_bridge: Bridge
|
||||
* BridgeBlindTransfer
|
||||
* - type: string (required)
|
||||
* - application: string (required)
|
||||
* - timestamp: Date
|
||||
* - bridge: Bridge
|
||||
* - channel: Channel (required)
|
||||
* - context: string (required)
|
||||
* - exten: string (required)
|
||||
* - is_external: boolean (required)
|
||||
* - result: string (required)
|
||||
* BridgeCreated
|
||||
* - type: string (required)
|
||||
* - application: string (required)
|
||||
|
Reference in New Issue
Block a user