Skip to content

Commit

Permalink
conference participant info by id (2600hz#2401)
Browse files Browse the repository at this point in the history
  • Loading branch information
onnet authored and lazedo committed Aug 4, 2016
1 parent 8bd5ea8 commit 695e932
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
10 changes: 10 additions & 0 deletions applications/crossbar/doc/ref/conferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
7 changes: 7 additions & 0 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -12947,6 +12953,7 @@
"put": {}
},
"/v2/accounts/{ACCOUNT_ID}/conferences/{CONFERENCE_ID}/participants/{PARTICIPANT_ID}": {
"get": {},
"put": {}
},
"/v2/accounts/{ACCOUNT_ID}/configs/{ID}": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
19 changes: 18 additions & 1 deletion applications/crossbar/src/modules/cb_conferences.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 695e932

Please sign in to comment.