From 695e932b7665d6627cc5caa7e264462033cd005c Mon Sep 17 00:00:00 2001 From: OnNet Date: Thu, 4 Aug 2016 11:21:14 +0300 Subject: [PATCH] conference participant info by id (#2401) --- applications/crossbar/doc/ref/conferences.md | 10 ++++++++++ applications/crossbar/priv/api/swagger.json | 7 +++++++ .../system_config.notify.account_crawler.json | 6 ++++++ .../crossbar/src/modules/cb_conferences.erl | 19 ++++++++++++++++++- 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/applications/crossbar/doc/ref/conferences.md b/applications/crossbar/doc/ref/conferences.md index ab61740f35e..90c55a19154 100644 --- a/applications/crossbar/doc/ref/conferences.md +++ b/applications/crossbar/doc/ref/conferences.md @@ -119,6 +119,16 @@ curl -v -X PUT \ http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/conferences/{CONFERENCE_ID}/participants ``` +#### Fetch + +> GET /v2/accounts/{ACCOUNT_ID}/conferences/{CONFERENCE_ID}/participants/{PARTICIPANT_ID} + +```curl +curl -v -X GET \ + -H "X-Auth-Token: {AUTH_TOKEN}" \ + http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}/conferences/{CONFERENCE_ID}/participants/{PARTICIPANT_ID} +``` + #### Create > PUT /v2/accounts/{ACCOUNT_ID}/conferences/{CONFERENCE_ID}/participants/{PARTICIPANT_ID} diff --git a/applications/crossbar/priv/api/swagger.json b/applications/crossbar/priv/api/swagger.json index 0a05d24ee48..b1bd7b1f110 100644 --- a/applications/crossbar/priv/api/swagger.json +++ b/applications/crossbar/priv/api/swagger.json @@ -9603,6 +9603,12 @@ "name": "crawl_for_low_balance", "type": "boolean" }, + "cycle_delay_time": { + "default": 300000, + "description": "", + "name": "cycle_delay_time", + "type": "integer" + }, "interaccount_delay": { "default": 10000, "description": "", @@ -12947,6 +12953,7 @@ "put": {} }, "/v2/accounts/{ACCOUNT_ID}/conferences/{CONFERENCE_ID}/participants/{PARTICIPANT_ID}": { + "get": {}, "put": {} }, "/v2/accounts/{ACCOUNT_ID}/configs/{ID}": { diff --git a/applications/crossbar/priv/couchdb/schemas/system_config.notify.account_crawler.json b/applications/crossbar/priv/couchdb/schemas/system_config.notify.account_crawler.json index 61cf504453d..03e329eaef6 100644 --- a/applications/crossbar/priv/couchdb/schemas/system_config.notify.account_crawler.json +++ b/applications/crossbar/priv/couchdb/schemas/system_config.notify.account_crawler.json @@ -15,6 +15,12 @@ "name": "crawl_for_low_balance", "type": "boolean" }, + "cycle_delay_time": { + "default": 300000, + "description": "", + "name": "cycle_delay_time", + "type": "integer" + }, "interaccount_delay": { "default": 10000, "description": "", diff --git a/applications/crossbar/src/modules/cb_conferences.erl b/applications/crossbar/src/modules/cb_conferences.erl index 89efe69b61e..5c29327ec40 100644 --- a/applications/crossbar/src/modules/cb_conferences.erl +++ b/applications/crossbar/src/modules/cb_conferences.erl @@ -82,7 +82,7 @@ init() -> allowed_methods() -> [?HTTP_GET, ?HTTP_PUT]. allowed_methods(_ConferenceId) -> [?HTTP_GET, ?HTTP_PATCH, ?HTTP_DELETE, ?HTTP_POST, ?HTTP_PUT]. allowed_methods(_ConferenceId, ?PARTICIPANTS) -> [?HTTP_GET, ?HTTP_PUT]. -allowed_methods(_ConferenceId, ?PARTICIPANTS, _ParticipantId) -> [?HTTP_PUT]. +allowed_methods(_ConferenceId, ?PARTICIPANTS, _ParticipantId) -> [?HTTP_GET, ?HTTP_PUT]. -spec resource_exists() -> 'true'. -spec resource_exists(path_token()) -> 'true'. @@ -142,6 +142,12 @@ validate_participants(?HTTP_PUT, Context, ConferenceId) -> load_conference(ConferenceId, Context). -spec validate_participant(http_method(), cb_context:context(), ne_binary(), ne_binary()) -> cb_context:context(). +validate_participant(?HTTP_GET, Context0, ConferenceId, ParticipantId) -> + Context1 = load_conference(ConferenceId, Context0), + case cb_context:resp_status(Context1) of + 'success' -> enrich_participant(ParticipantId, ConferenceId, Context1); + _Else -> Context1 + end; validate_participant(?HTTP_PUT, Context, ConferenceId, _ParticipantId) -> load_conference(ConferenceId, Context). @@ -324,6 +330,17 @@ perform_participant_action(Conference, ?KICK, ParticipantId) -> kapps_conference_command:kick(ParticipantId, Conference). %% add real-time call-info to participants +-spec enrich_participant(ne_binary(), ne_binary(), cb_context:context()) -> cb_context:context(). +enrich_participant(ParticipantId, ConferenceId, Context) -> + Participants = extract_participants( + request_conference_details(ConferenceId) + ), + [Normalized|_] = [kz_json:normalize_jobj(JObj) + || JObj <- request_call_details(Participants) + ,kz_json:get_binary_value(<<"Participant-ID">>, JObj) == ParticipantId + ] ++ [kz_json:new()], + crossbar_util:response(Normalized, Context). + -spec enrich_participants(ne_binary(), cb_context:context()) -> cb_context:context(). enrich_participants(ConferenceId, Context) -> Participants = extract_participants(