25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

Include actor element in MUC stanzas when kicking (thanks to Purvesh Sahoo)(EJAB-1206)

This commit is contained in:
Badlop 2013-04-23 10:27:04 +02:00
parent 9fa415e557
commit 066c47ca96

View File

@ -2593,7 +2593,7 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
SD; SD;
{JID, role, none, Reason} -> {JID, role, none, Reason} ->
catch catch
send_kickban_presence(JID, send_kickban_presence(UJID, JID,
Reason, Reason,
<<"307">>, <<"307">>,
SD), SD),
@ -2605,7 +2605,7 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
of of
true -> true ->
catch catch
send_kickban_presence(JID, send_kickban_presence(UJID, JID,
Reason, Reason,
<<"321">>, <<"321">>,
none, none,
@ -2628,7 +2628,7 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
{JID, affiliation, outcast, {JID, affiliation, outcast,
Reason} -> Reason} ->
catch catch
send_kickban_presence(JID, send_kickban_presence(UJID, JID,
Reason, Reason,
<<"301">>, <<"301">>,
outcast, outcast,
@ -2979,12 +2979,12 @@ can_change_ra(_FAffiliation, _FRole, _TAffiliation,
_TRole, role, _Value, _ServiceAf) -> _TRole, role, _Value, _ServiceAf) ->
false. false.
send_kickban_presence(JID, Reason, Code, StateData) -> send_kickban_presence(UJID, JID, Reason, Code, StateData) ->
NewAffiliation = get_affiliation(JID, StateData), NewAffiliation = get_affiliation(JID, StateData),
send_kickban_presence(JID, Reason, Code, NewAffiliation, send_kickban_presence(UJID, JID, Reason, Code, NewAffiliation,
StateData). StateData).
send_kickban_presence(JID, Reason, Code, NewAffiliation, send_kickban_presence(UJID, JID, Reason, Code, NewAffiliation,
StateData) -> StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jlib:jid_tolower(JID),
LJIDs = case LJID of LJIDs = case LJID of
@ -3007,18 +3007,27 @@ send_kickban_presence(JID, Reason, Code, NewAffiliation,
StateData#state.users), StateData#state.users),
add_to_log(kickban, {Nick, Reason, Code}, StateData), add_to_log(kickban, {Nick, Reason, Code}, StateData),
tab_remove_online_user(J, StateData), tab_remove_online_user(J, StateData),
send_kickban_presence1(J, Reason, Code, send_kickban_presence1(UJID, J, Reason, Code,
NewAffiliation, StateData) NewAffiliation, StateData)
end, end,
LJIDs). LJIDs).
send_kickban_presence1(UJID, Reason, Code, Affiliation, send_kickban_presence1(MJID, UJID, Reason, Code, Affiliation,
StateData) -> StateData) ->
{ok, #user{jid = RealJID, nick = Nick}} = {ok, #user{jid = RealJID, nick = Nick}} =
(?DICT):find(jlib:jid_tolower(UJID), (?DICT):find(jlib:jid_tolower(UJID),
StateData#state.users), StateData#state.users),
SAffiliation = affiliation_to_list(Affiliation), SAffiliation = affiliation_to_list(Affiliation),
BannedJIDString = jlib:jid_to_string(RealJID), BannedJIDString = jlib:jid_to_string(RealJID),
case MJID /= <<"">> of
true ->
{ok, #user{jid = RealMJID}} =
(?DICT):find(jlib:jid_tolower(MJID),
StateData#state.users),
ActorJIDString = jlib:jid_to_string(RealMJID);
false ->
ActorJIDString = <<"">>
end,
lists:foreach(fun ({_LJID, Info}) -> lists:foreach(fun ({_LJID, Info}) ->
JidAttrList = case Info#user.role == moderator orelse JidAttrList = case Info#user.role == moderator orelse
(StateData#state.config)#config.anonymous (StateData#state.config)#config.anonymous
@ -3039,6 +3048,12 @@ send_kickban_presence1(UJID, Reason, Code, Affiliation,
children = children =
[{xmlcdata, Reason}]}] [{xmlcdata, Reason}]}]
end, end,
ItemElsActor = case MJID of
<<"">> -> [];
_ -> [#xmlel{name = <<"actor">>,
attrs =
[{<<"jid">>, ActorJIDString}]}]
end,
Packet = #xmlel{name = <<"presence">>, Packet = #xmlel{name = <<"presence">>,
attrs = attrs =
[{<<"type">>, <<"unavailable">>}], [{<<"type">>, <<"unavailable">>}],
@ -3053,7 +3068,7 @@ send_kickban_presence1(UJID, Reason, Code, Affiliation,
attrs = attrs =
ItemAttrs, ItemAttrs,
children = children =
ItemEls}, ItemElsActor ++ ItemEls},
#xmlel{name = #xmlel{name =
<<"status">>, <<"status">>,
attrs = attrs =
@ -3067,6 +3082,7 @@ send_kickban_presence1(UJID, Reason, Code, Affiliation,
end, end,
(?DICT):to_list(StateData#state.users)). (?DICT):to_list(StateData#state.users)).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Owner stuff % Owner stuff
@ -3751,7 +3767,7 @@ remove_nonmembers(StateData) ->
Affiliation = get_affiliation(JID, SD), Affiliation = get_affiliation(JID, SD),
case Affiliation of case Affiliation of
none -> none ->
catch send_kickban_presence(JID, <<"">>, catch send_kickban_presence(<<"">>, JID, <<"">>,
<<"322">>, SD), <<"322">>, SD),
set_role(JID, none, SD); set_role(JID, none, SD);
_ -> SD _ -> SD