diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index c1273d0dc..2ec5baaf0 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -52,7 +52,8 @@ -export([get_presence/1, set_presence/2, resend_presence/1, resend_presence/2, open_session/1, call/3, cast/2, send/2, close/1, close/2, stop_async/1, reply/2, copy_state/2, set_timeout/2, route/2, format_reason/2, - host_up/1, host_down/1, send_ws_ping/1, bounce_message_queue/2]). + host_up/1, host_down/1, send_ws_ping/1, bounce_message_queue/2, + reset_vcard_xupdate_resend_presence/1]). -include_lib("xmpp/include/xmpp.hrl"). -include("logger.hrl"). @@ -108,6 +109,10 @@ resend_presence(Pid) -> resend_presence(Pid, To) -> route(Pid, {resend_presence, To}). +-spec reset_vcard_xupdate_resend_presence(pid()) -> boolean(). +reset_vcard_xupdate_resend_presence(Pid) -> + route(Pid, reset_vcard_xupdate_resend_presence). + -spec close(pid()) -> ok; (state()) -> state(). close(Ref) -> @@ -246,6 +251,13 @@ process_info(#{lserver := LServer} = State, {route, Packet}) -> true -> State1 end; +process_info(State, reset_vcard_xupdate_resend_presence) -> + case maps:get(pres_last, State, error) of + error -> State; + Pres -> + Pres2 = xmpp:remove_subtag(Pres, #vcard_xupdate{}), + process_self_presence(State#{pres_last => Pres2}, Pres2) + end; process_info(#{jid := JID} = State, {resend_presence, To}) -> case maps:get(pres_last, State, error) of error -> State; diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 1ff539ad1..b986d5400 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -56,6 +56,7 @@ get_vh_session_number/1, get_vh_by_backend/1, force_update_presence/1, + reset_vcard_xupdate_resend_presence/1, connected_users/0, connected_users_number/0, user_resources/2, @@ -926,6 +927,15 @@ force_update_presence({LUser, LServer}) -> end, Ss). +-spec reset_vcard_xupdate_resend_presence({binary(), binary()}) -> ok. +reset_vcard_xupdate_resend_presence({LUser, LServer}) -> + Mod = get_sm_backend(LServer), + Ss = get_sessions(Mod, LUser, LServer), + lists:foreach( + fun(#session{sid = {_, Pid}}) -> + ejabberd_c2s:reset_vcard_xupdate_resend_presence(Pid) + end, Ss). + -spec get_sm_backend(binary()) -> module(). get_sm_backend(Host) -> diff --git a/src/mod_vcard_xupdate.erl b/src/mod_vcard_xupdate.erl index e6a26864c..0b6367684 100644 --- a/src/mod_vcard_xupdate.erl +++ b/src/mod_vcard_xupdate.erl @@ -97,7 +97,7 @@ user_send_packet(Acc) -> -spec vcard_set(iq()) -> iq(). vcard_set(#iq{from = #jid{luser = LUser, lserver = LServer}} = IQ) -> ets_cache:delete(?VCARD_XUPDATE_CACHE, {LUser, LServer}, ejabberd_cluster:get_nodes()), - ejabberd_sm:force_update_presence({LUser, LServer}), + ejabberd_sm:reset_vcard_xupdate_resend_presence({LUser, LServer}), IQ; vcard_set(Acc) -> Acc.