From c2c8587c6fcaeb04dd8ee7e568b6ee551e809d83 Mon Sep 17 00:00:00 2001 From: sennui Date: Wed, 24 Jun 2020 17:01:49 +0200 Subject: [PATCH] handle voip pushes with non-voip token for china store --- apps/roster/src/api/push/roster_apns_api.erl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/roster/src/api/push/roster_apns_api.erl b/apps/roster/src/api/push/roster_apns_api.erl index 88e050dbc..0a7c00734 100644 --- a/apps/roster/src/api/push/roster_apns_api.erl +++ b/apps/roster/src/api/push/roster_apns_api.erl @@ -37,7 +37,7 @@ -define(FKPN_BUNDLE, <<"IOS_BANDLE">>). %% Sic! -define(FKPN_GATEWAY, <<"APNS_GATEWAY">>). -define(FKPN_SERVER_DNS, <<"SERVER_DNS">>). --define(FKPN_GENERIC_TOKEN, <<"GENERIC_TOKEN">>). +-define(FKPN_TOKEN_GENERIC, <<"TOKEN_GENERIC">>). %% Temporary manual interface @@ -109,7 +109,7 @@ notify(A, C, T, VoipToken, SessionSettings, PushType, State) -> pick_connection_type(PushType, SessionSettings, VoipToken) -> %% Note that headers need to be written as strings. %% The payload content should be numbers. - case push_type_and_token(PushType, SessionSettings) of + case push_type_and_token(PushType, SessionSettings, VoipToken) of {background, Token} -> Headers = #{ apns_push_type => <<"background">> , apns_priority => <<"5">>}, @@ -127,18 +127,20 @@ pick_connection_type(PushType, SessionSettings, VoipToken) -> false -> {binary, VoipToken} end; - voip -> + {voip, VoipTokenForDevice} -> Headers = #{ apns_push_type => <<"voip">> , apns_expiration => <<"0">> %% Deliver immediately or not at all. , apns_priority => <<"10">>}, Aps = #{}, - {http, Headers, Aps, VoipToken} + {http, Headers, Aps, VoipTokenForDevice} end. -push_type_and_token(<<"voip">>, _SessionSettings) -> - voip; -push_type_and_token(_PushType, SessionSettings) -> - case get_data_from_feature(SessionSettings, ?FKPN_GENERIC_TOKEN) of +push_type_and_token(<<"voip">>, SessionSettings, []) -> + {voip, get_data_from_feature(SessionSettings, ?FKPN_TOKEN_GENERIC)}; +push_type_and_token(<<"voip">>, _SessionSettings, VoipToken) -> + {voip, VoipToken}; +push_type_and_token(_PushType, SessionSettings, _VoipToken) -> + case get_data_from_feature(SessionSettings, ?FKPN_TOKEN_GENERIC) of [] -> binary; Token -> {background, Token} end. -- GitLab