mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-20 16:15:59 +01:00
Make mod_vcard_xupdate send hash after avatar get set for first time
We need to remove info about empty photo in session stored presence after avatar get set, otherwise as we don't modify presences like that in mod_vcard_xupdate, we will send presence with updated hash. This fixes issue #4182
This commit is contained in:
parent
537aac24f7
commit
c5437235f3
@ -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;
|
||||
|
@ -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) ->
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user