24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-02 21:17:12 +02:00

* src/mod_muc/mod_muc_room.erl: Support Reasons for all

affiliation and role changes (EJAB-306)

SVN Revision: 1498
This commit is contained in:
Badlop 2008-07-30 18:24:08 +00:00
parent 2660bc514f
commit 756cd06625
2 changed files with 28 additions and 12 deletions

View File

@ -1,5 +1,8 @@
2008-07-30 Badlop <badlop@process-one.net> 2008-07-30 Badlop <badlop@process-one.net>
* src/mod_muc/mod_muc_room.erl: Support Reasons for all
affiliation and role changes (EJAB-306)
* src/gen_mod.erl: When ejabberd is kindly stopped, don't forget * src/gen_mod.erl: When ejabberd is kindly stopped, don't forget
modules configuration (EJAB-706) modules configuration (EJAB-706)
* src/ejabberd_app.erl: Likewise * src/ejabberd_app.erl: Likewise

View File

@ -1701,6 +1701,9 @@ extract_history([_ | Els], Type) ->
send_update_presence(JID, StateData) -> send_update_presence(JID, StateData) ->
send_update_presence(JID, "", StateData).
send_update_presence(JID, Reason, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jlib:jid_tolower(JID),
LJIDs = case LJID of LJIDs = case LJID of
{U, S, ""} -> {U, S, ""} ->
@ -1722,10 +1725,13 @@ send_update_presence(JID, StateData) ->
end end
end, end,
lists:foreach(fun(J) -> lists:foreach(fun(J) ->
send_new_presence(J, StateData) send_new_presence(J, Reason, StateData)
end, LJIDs). end, LJIDs).
send_new_presence(NJID, StateData) -> send_new_presence(NJID, StateData) ->
send_new_presence(NJID, "", StateData).
send_new_presence(NJID, Reason, StateData) ->
{ok, #user{jid = RealJID, {ok, #user{jid = RealJID,
nick = Nick, nick = Nick,
role = Role, role = Role,
@ -1747,6 +1753,13 @@ send_new_presence(NJID, StateData) ->
[{"affiliation", SAffiliation}, [{"affiliation", SAffiliation},
{"role", SRole}] {"role", SRole}]
end, end,
ItemEls = case Reason of
"" ->
[];
_ ->
[{xmlelement, "reason", [],
[{xmlcdata, Reason}]}]
end,
Status = case StateData#state.just_created of Status = case StateData#state.just_created of
true -> true ->
[{xmlelement, "status", [{"code", "201"}], []}]; [{xmlelement, "status", [{"code", "201"}], []}];
@ -1756,7 +1769,7 @@ send_new_presence(NJID, StateData) ->
Packet = append_subtags( Packet = append_subtags(
Presence, Presence,
[{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}], [{xmlelement, "x", [{"xmlns", ?NS_MUC_USER}],
[{xmlelement, "item", ItemAttrs, []} | Status]}]), [{xmlelement, "item", ItemAttrs, ItemEls} | Status]}]),
ejabberd_router:route( ejabberd_router:route(
jlib:jid_replace_resource(StateData#state.jid, Nick), jlib:jid_replace_resource(StateData#state.jid, Nick),
Info#user.jid, Info#user.jid,
@ -2124,21 +2137,21 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
set_affiliation_and_reason( set_affiliation_and_reason(
JID, outcast, Reason, JID, outcast, Reason,
set_role(JID, none, SD)); set_role(JID, none, SD));
{JID, affiliation, A, _Reason} when {JID, affiliation, A, Reason} when
(A == admin) or (A == owner) -> (A == admin) or (A == owner) ->
SD1 = set_affiliation(JID, A, SD), SD1 = set_affiliation_and_reason(JID, A, Reason, SD),
SD2 = set_role(JID, moderator, SD1), SD2 = set_role(JID, moderator, SD1),
send_update_presence(JID, SD2), send_update_presence(JID, Reason, SD2),
SD2; SD2;
{JID, affiliation, member, _Reason} -> {JID, affiliation, member, Reason} ->
SD1 = set_affiliation( SD1 = set_affiliation_and_reason(
JID, member, SD), JID, member, Reason, SD),
SD2 = set_role(JID, participant, SD1), SD2 = set_role(JID, participant, SD1),
send_update_presence(JID, SD2), send_update_presence(JID, Reason, SD2),
SD2; SD2;
{JID, role, R, _Reason} -> {JID, role, Role, Reason} ->
SD1 = set_role(JID, R, SD), SD1 = set_role(JID, Role, SD),
catch send_new_presence(JID, SD1), catch send_new_presence(JID, Reason, SD1),
SD1; SD1;
{JID, affiliation, A, _Reason} -> {JID, affiliation, A, _Reason} ->
SD1 = set_affiliation(JID, A, SD), SD1 = set_affiliation(JID, A, SD),