mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Fix nick-to-jid mapping for MUC subscribers
This commit is contained in:
parent
d0761039ff
commit
1aca541639
@ -106,6 +106,7 @@
|
|||||||
config = #config{} :: config(),
|
config = #config{} :: config(),
|
||||||
users = (?DICT):new() :: ?TDICT,
|
users = (?DICT):new() :: ?TDICT,
|
||||||
subscribers = (?DICT):new() :: ?TDICT,
|
subscribers = (?DICT):new() :: ?TDICT,
|
||||||
|
subscriber_nicks = (?DICT):new() :: ?TDICT,
|
||||||
last_voice_request_time = treap:empty() :: treap:treap(),
|
last_voice_request_time = treap:empty() :: treap:treap(),
|
||||||
robots = (?DICT):new() :: ?TDICT,
|
robots = (?DICT):new() :: ?TDICT,
|
||||||
nicks = (?DICT):new() :: ?TDICT,
|
nicks = (?DICT):new() :: ?TDICT,
|
||||||
|
@ -1743,12 +1743,15 @@ update_online_user(JID, #user{nick = Nick} = User, StateData) ->
|
|||||||
|
|
||||||
set_subscriber(JID, Nick, Nodes, StateData) ->
|
set_subscriber(JID, Nick, Nodes, StateData) ->
|
||||||
BareJID = jid:remove_resource(JID),
|
BareJID = jid:remove_resource(JID),
|
||||||
Subscribers = ?DICT:store(jid:tolower(BareJID),
|
LBareJID = jid:tolower(BareJID),
|
||||||
|
Subscribers = ?DICT:store(LBareJID,
|
||||||
#subscriber{jid = BareJID,
|
#subscriber{jid = BareJID,
|
||||||
nick = Nick,
|
nick = Nick,
|
||||||
nodes = Nodes},
|
nodes = Nodes},
|
||||||
StateData#state.subscribers),
|
StateData#state.subscribers),
|
||||||
NewStateData = StateData#state{subscribers = Subscribers},
|
Nicks = ?DICT:store(Nick, [LBareJID], StateData#state.subscriber_nicks),
|
||||||
|
NewStateData = StateData#state{subscribers = Subscribers,
|
||||||
|
subscriber_nicks = Nicks},
|
||||||
store_room(NewStateData),
|
store_room(NewStateData),
|
||||||
NewStateData.
|
NewStateData.
|
||||||
|
|
||||||
@ -1833,10 +1836,13 @@ add_user_presence_un(JID, Presence, StateData) ->
|
|||||||
%% Find and return a list of the full JIDs of the users of Nick.
|
%% Find and return a list of the full JIDs of the users of Nick.
|
||||||
%% Return jid record.
|
%% Return jid record.
|
||||||
find_jids_by_nick(Nick, StateData) ->
|
find_jids_by_nick(Nick, StateData) ->
|
||||||
case (?DICT):find(Nick, StateData#state.nicks) of
|
Nicks = ?DICT:merge(fun(_, Val, _) -> Val end,
|
||||||
{ok, [User]} -> [jid:make(User)];
|
StateData#state.nicks,
|
||||||
{ok, Users} -> [jid:make(LJID) || LJID <- Users];
|
StateData#state.subscriber_nicks),
|
||||||
error -> false
|
case (?DICT):find(Nick, Nicks) of
|
||||||
|
{ok, [User]} -> [jid:make(User)];
|
||||||
|
{ok, Users} -> [jid:make(LJID) || LJID <- Users];
|
||||||
|
error -> false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% Find and return the full JID of the user of Nick with
|
%% Find and return the full JID of the user of Nick with
|
||||||
@ -1903,7 +1909,14 @@ is_nick_change(JID, Nick, StateData) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
nick_collision(User, Nick, StateData) ->
|
nick_collision(User, Nick, StateData) ->
|
||||||
UserOfNick = find_jid_by_nick(Nick, StateData),
|
UserOfNick = case find_jid_by_nick(Nick, StateData) of
|
||||||
|
false ->
|
||||||
|
case ?DICT:find(Nick, StateData#state.subscriber_nicks) of
|
||||||
|
{ok, [J]} -> J;
|
||||||
|
error -> false
|
||||||
|
end;
|
||||||
|
J -> J
|
||||||
|
end,
|
||||||
(UserOfNick /= false andalso
|
(UserOfNick /= false andalso
|
||||||
jid:remove_resource(jid:tolower(UserOfNick))
|
jid:remove_resource(jid:tolower(UserOfNick))
|
||||||
/= jid:remove_resource(jid:tolower(User))).
|
/= jid:remove_resource(jid:tolower(User))).
|
||||||
@ -4646,10 +4659,17 @@ process_iq_mucsub(From, _Packet,
|
|||||||
sub_el = #xmlel{name = <<"unsubscribe">>}},
|
sub_el = #xmlel{name = <<"unsubscribe">>}},
|
||||||
StateData) ->
|
StateData) ->
|
||||||
LBareJID = jid:tolower(jid:remove_resource(From)),
|
LBareJID = jid:tolower(jid:remove_resource(From)),
|
||||||
Subscribers = ?DICT:erase(LBareJID, StateData#state.subscribers),
|
case ?DICT:find(LBareJID, StateData#state.subscribers) of
|
||||||
NewStateData = StateData#state{subscribers = Subscribers},
|
{ok, #subscriber{nick = Nick}} ->
|
||||||
store_room(NewStateData),
|
Nicks = ?DICT:erase(Nick, StateData#state.subscriber_nicks),
|
||||||
{result, [], NewStateData};
|
Subscribers = ?DICT:erase(LBareJID, StateData#state.subscribers),
|
||||||
|
NewStateData = StateData#state{subscribers = Subscribers,
|
||||||
|
subscriber_nicks = Nicks},
|
||||||
|
store_room(NewStateData),
|
||||||
|
{result, [], NewStateData};
|
||||||
|
error ->
|
||||||
|
{result, [], StateData}
|
||||||
|
end;
|
||||||
process_iq_mucsub(From, _Packet,
|
process_iq_mucsub(From, _Packet,
|
||||||
#iq{type = get, lang = Lang,
|
#iq{type = get, lang = Lang,
|
||||||
sub_el = #xmlel{name = <<"subscriptions">>}},
|
sub_el = #xmlel{name = <<"subscriptions">>}},
|
||||||
@ -4674,7 +4694,8 @@ process_iq_mucsub(_From, _Packet, #iq{lang = Lang}, _StateData) ->
|
|||||||
|
|
||||||
remove_subscriptions(StateData) ->
|
remove_subscriptions(StateData) ->
|
||||||
if not (StateData#state.config)#config.allow_subscription ->
|
if not (StateData#state.config)#config.allow_subscription ->
|
||||||
StateData#state{subscribers = ?DICT:new()};
|
StateData#state{subscribers = ?DICT:new(),
|
||||||
|
subscriber_nicks = ?DICT:new()};
|
||||||
true ->
|
true ->
|
||||||
StateData
|
StateData
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user