res/ari: Add the Asterisk EID field to outgoing events

This patch adds the Asterisk EID field to all outgoing ARI events.
Because this field should be added to all events as they are
transmitted, it is appended to the JSON message just prior to it being
handed off to the application message handler. This makes it somewhat
resilient to both new events being added to ARI, as well as other
potential event transport mechanisms.

ASTERISK-26470 #close

Change-Id: Ieff0ecc24464e83f3f44e9c3e7bd9a5d70b87a1d
This commit is contained in:
Matt Jordan
2016-10-15 20:05:05 -05:00
committed by George Joseph
parent 5df575e16a
commit dd5129d84a
6 changed files with 403 additions and 2 deletions

View File

@@ -929,8 +929,15 @@ struct stasis_topic *ast_app_get_topic(struct stasis_app *app)
void app_send(struct stasis_app *app, struct ast_json *message)
{
stasis_app_cb handler;
char eid[20];
RAII_VAR(void *, data, NULL, ao2_cleanup);
if (ast_json_object_set(message, "asterisk_id", ast_json_string_create(
ast_eid_to_str(eid, sizeof(eid), &ast_eid_default)))) {
ast_log(AST_LOG_WARNING, "Failed to append EID to outgoing event %s\n",
ast_json_string_get(ast_json_object_get(message, "type")));
}
/* Copy off mutable state with lock held */
{
SCOPED_AO2LOCK(lock, app);