diff --git a/res/ari/resource_bridges.c b/res/ari/resource_bridges.c index e4e70641a9453a826baf90cf7d82bf0058dbdfb3..d03e86f5615afd2eba880e19d7cee540e8d71ba8 100644 --- a/res/ari/resource_bridges.c +++ b/res/ari/resource_bridges.c @@ -905,12 +905,23 @@ void ast_ari_bridges_list(struct ast_variable *headers, i = ao2_iterator_init(bridges, 0); while ((bridge = ao2_iterator_next(&i))) { - struct ast_bridge_snapshot *snapshot = ast_bridge_get_snapshot(bridge); - /* ast_bridge_snapshot_to_json will return NULL if snapshot is NULL */ - struct ast_json *json_bridge = ast_bridge_snapshot_to_json(snapshot, stasis_app_get_sanitizer()); + struct ast_bridge_snapshot *snapshot; + struct ast_json *json_bridge = NULL; + + /* Invisible bridges don't get shown externally and have no snapshot */ + if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_INVISIBLE)) { + ao2_ref(bridge, -1); + continue; + } + + snapshot = ast_bridge_get_snapshot(bridge); + if (snapshot) { + json_bridge = ast_bridge_snapshot_to_json(snapshot, stasis_app_get_sanitizer()); + ao2_ref(snapshot, -1); + } ao2_ref(bridge, -1); - ao2_cleanup(snapshot); + if (!json_bridge || ast_json_array_append(json, json_bridge)) { ao2_iterator_destroy(&i); ast_ari_response_alloc_failed(response);