Skip to content

Commit

Permalink
check presence_id (2600hz#6510)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazedo authored May 1, 2020
1 parent 8599434 commit 6117aad
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ publish_presence(#{call_id := UUID, payload := _JObj} = Ctx) ->
kz_log:put_callid(UUID),
Routines = [fun check_proto/1
,fun check_node/1
,fun check_presence_id/1
],
case lists:all(fun(F) -> F(Ctx) end, Routines) of
'true' -> build_presence_event(UUID, Ctx);
Expand Down Expand Up @@ -60,9 +61,15 @@ check_node(#{payload := JObj}) ->
'false' -> 'true';
'undefined' -> 'true';
Node -> 'true';
_Other -> 'false'
_Other ->
lager:debug("check node failed ~p ", [_Other]),
'false'
end.

-spec check_presence_id(map()) -> boolean().
check_presence_id(#{payload := JObj}) ->
kz_call_event:custom_channel_var(JObj, <<"Presence-ID">>) =/= 'undefined'.

-spec realm(kz_json:object()) -> kz_term:ne_binary().
realm(JObj) ->
kz_json:get_first_defined([?GET_CCV(<<"Realm">>)
Expand All @@ -83,7 +90,8 @@ get_user_realm(JObj) ->

-spec from(kz_json:object()) -> kz_term:ne_binary().
from(JObj) ->
kz_json:get_first_defined([<<"from">>
kz_json:get_first_defined([?GET_CCV(<<"Presence-ID">>)
,<<"from">>
,<<"variable_presence_id">>
,<<"Channel-Presence-ID">>
]
Expand Down

0 comments on commit 6117aad

Please sign in to comment.