diff --git a/apps/roster/src/protocol/roster_presence.erl b/apps/roster/src/protocol/roster_presence.erl index b184d0bb199a48869b7cf571c7d3dc7d3fcd0a20..68ca6c17385ae92a4587a53bd5d94b7ce5fc973c 100644 --- a/apps/roster/src/protocol/roster_presence.erl +++ b/apps/roster/src/protocol/roster_presence.erl @@ -22,7 +22,8 @@ on_connect(Phone, ClientId, C, Ver) -> case send_presence(online, Phone, C, ClientId) of {error, profile_not_found} -> roster:info(?MODULE, "~p:~p:Connect:ProfileNotFound", [Phone, ClientId]), roster:delete_sessions(Phone); - #'Profile'{} = P when Ver==?VERSION -> roster:send_cache(ClientId, C); + #'Profile'{} = P when Ver==?VERSION -> + roster:send_cache(ClientId, C); #'Profile'{} = P-> roster:send_profile(P#'Profile'{settings = amazon_settings(P), status = init}, [], 0, ClientId, C), roster:send_cache(ClientId, C) @@ -56,11 +57,15 @@ send_presence(Status, Phone, C, ClientId) when Status == online; Status == offli PhoneId = roster:phone_id(Phone, AccId), [roster:Send(C, PhoneId, #'Contact'{phone_id = PhoneId, presence = Status, update = Now, status = internal}) || Send <- [send_muc, send_ac]]; - #error{} -> skip + {error, _} -> skip end || AccId <- Rosters], P2; - _ -> roster:info(?MODULE, "~p:~p:~p",[Phone, ClientId,P]), P end; - _ -> {error, profile_not_found} end. + _ -> + roster:info(?MODULE, "~p:~p:~p",[Phone, ClientId,P]), + P + end; + _ -> {error, profile_not_found} + end. send_presence(Status, PhoneId, C) -> diff --git a/apps/roster/src/roster.erl b/apps/roster/src/roster.erl index e3b47bed8071ecf536ca933638e9d8e5cba2d324..094ff5327e58a5572e2a587025812a70506f4f36 100644 --- a/apps/roster/src/roster.erl +++ b/apps/roster/src/roster.erl @@ -571,7 +571,8 @@ unload() -> on_client_disconnected(_Reason, #mqtt_client{client_id = <<"emqttd_", _/bytes>> = ClientId}, _Env) -> % TODO: mqttc:publish(C, lists:concat(["ses/",Phone])) on_disconnect(ClientId); -on_client_disconnected(_Reason, #mqtt_client{client_id = <<"reg_", _/bytes>> = ClientId}, _) -> final_disconnect(ClientId); +on_client_disconnected(_Reason, #mqtt_client{client_id = <<"reg_", _/bytes>> = ClientId}, _) -> + final_disconnect(ClientId); on_client_disconnected(_Reason, _Client = #mqtt_client{}, _Env) -> ok. on_disconnect(<<"emqttd_", _/binary>> = ClientId) -> info(roster_auth, "~p:CLIENT DISCONNECT",[ClientId]), @@ -2282,5 +2283,13 @@ cache_ses(PhoneId, Term) -> send_cache(#'Auth'{client_id = ClientId, settings = Settings} = Auth, C) -> [send_action(C, ClientId, V) || #'Feature'{key = <<"cache_", _/binary>>, value = V} <- Settings], case [F||#'Feature'{group = Group} = F <- Settings, Group /= <<"CACHE_GROUP">>] of - Settings -> ok; S -> kvs:put(Auth#'Auth'{settings = S}) end; -send_cache(ClientId, C) -> send_cache(element(2, kvs:get('Auth', ClientId)), C). + Settings -> + ok; + S -> + kvs:put(Auth#'Auth'{settings = S}) + end; +send_cache(ClientId, C) -> + case kvs:get('Auth', ClientId) of + {ok, Auth} -> send_cache(Auth, C); + Error -> Error + end. diff --git a/sys.config b/sys.config index f915adf547dd9a1acc0c1f3eeab3416601405a71..b5a672370240f78014d1181c913bb16f9cc5bafd 100644 --- a/sys.config +++ b/sys.config @@ -8,6 +8,7 @@ {custom_validate, {roster, validate}}, {swift,"apps/roster/priv/macbert/"}]}, {roster,[ + {freeze_time, 1000}, {upload,"./storage"}, {email_api,[ {from,<<"Nynja App">>},