From b8c6d52d96485f5e219162b9fc051f3faac534d4 Mon Sep 17 00:00:00 2001 From: James Aimonetti Date: Fri, 10 Apr 2020 16:04:10 -0700 Subject: [PATCH] HELP-12949: Calculate presence ID from FS events (#6463) --- applications/ecallmgr/src/ecallmgr_maintenance.erl | 2 +- .../ecallmgr_presence_event_publisher.erl | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/applications/ecallmgr/src/ecallmgr_maintenance.erl b/applications/ecallmgr/src/ecallmgr_maintenance.erl index 42d66a2a4f5..7ea7b9ebb04 100644 --- a/applications/ecallmgr/src/ecallmgr_maintenance.erl +++ b/applications/ecallmgr/src/ecallmgr_maintenance.erl @@ -620,7 +620,7 @@ list_acls(ACLs, Network) -> Props = kz_json:foldl(fun(Name, ACL, Acc) -> [{kz_json:get_value(<<"network-list-name">>, ACL) ,kz_json:set_value(<<"name">>, Name, ACL)} - | Acc + | Acc ] end, [], ACLs), _ = [maybe_print_acl(Network, FormatString, ACL) diff --git a/applications/ecallmgr/src/event_publish/ecallmgr_presence_event_publisher.erl b/applications/ecallmgr/src/event_publish/ecallmgr_presence_event_publisher.erl index 33812e2244d..22f29fdb7a6 100644 --- a/applications/ecallmgr/src/event_publish/ecallmgr_presence_event_publisher.erl +++ b/applications/ecallmgr/src/event_publish/ecallmgr_presence_event_publisher.erl @@ -90,6 +90,16 @@ from(JObj) -> ,JObj ). +-spec presence_id(kz_json:object(), kz_term:ne_binary()) -> kz_term:ne_binary(). +presence_id(JObj, Realm) -> + PresenceId = kz_json:get_first_defined([<<"Channel-Presence-ID">> + ,<<"variable_presence_id">> + ] + ,JObj + ), + [Id|_] = binary:split(PresenceId, <<"@">>), + <>. + -spec to_user(kz_json:object()) -> kz_term:ne_binary(). to_user(JObj) -> to_user(direction(JObj), JObj). @@ -118,7 +128,7 @@ build_presence_event(UUID, #{payload := JObj}) -> FromTag = kz_evt_freeswitch:from_tag(JObj), {FromUser, Realm} = get_user_realm(JObj), - PresenceId = <>, + PresenceId = presence_id(JObj, Realm), PresenceURI = <<"sip:", PresenceId/binary>>, ToUser = to_user(JObj),