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

* src/mod_muc/mod_muc_room.erl: Store ban reasons for outcast

items, updated affiliation matching rules to latest JEP-0045

SVN Revision: 339
This commit is contained in:
Alexey Shchepin 2005-05-03 23:07:14 +00:00
parent fd118302bc
commit 22ca77c1c2
2 changed files with 69 additions and 18 deletions

View File

@ -1,3 +1,8 @@
2005-05-04 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc_room.erl: Store ban reasons for outcast
items, updated affiliation matching rules to latest JEP-0045
2005-05-02 Alexey Shchepin <alexey@sevcom.net> 2005-05-02 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc_room.erl: Updated changing roles and * src/mod_muc/mod_muc_room.erl: Updated changing roles and

View File

@ -547,7 +547,6 @@ normal_state({route, From, ToNick,
{next_state, normal_state, StateData}; {next_state, normal_state, StateData};
normal_state(Event, StateData) -> normal_state(Event, StateData) ->
io:format("MUC: unknown event ~p~n", [Event]),
{next_state, normal_state, StateData}. {next_state, normal_state, StateData}.
@ -708,19 +707,57 @@ set_affiliation(JID, Affiliation, StateData) ->
end, end,
StateData#state{affiliations = Affiliations}. StateData#state{affiliations = Affiliations}.
set_affiliation_and_reason(JID, Affiliation, Reason, StateData) ->
LJID = jlib:jid_remove_resource(jlib:jid_tolower(JID)),
Affiliations = case Affiliation of
none ->
?DICT:erase(LJID,
StateData#state.affiliations);
_ ->
?DICT:store(LJID,
{Affiliation, Reason},
StateData#state.affiliations)
end,
StateData#state{affiliations = Affiliations}.
get_affiliation(JID, StateData) -> get_affiliation(JID, StateData) ->
{_AccessRoute, _AccessCreate, AccessAdmin} = StateData#state.access, {_AccessRoute, _AccessCreate, AccessAdmin} = StateData#state.access,
Res =
case acl:match_rule(AccessAdmin, JID) of case acl:match_rule(AccessAdmin, JID) of
allow -> allow ->
owner; owner;
_ -> _ ->
LJID = jlib:jid_remove_resource(jlib:jid_tolower(JID)), LJID = jlib:jid_tolower(JID),
case ?DICT:find(LJID, StateData#state.affiliations) of case ?DICT:find(LJID, StateData#state.affiliations) of
{ok, Affiliation} ->
Affiliation;
_ ->
LJID1 = jlib:jid_remove_resource(LJID),
case ?DICT:find(LJID1, StateData#state.affiliations) of
{ok, Affiliation} ->
Affiliation;
_ ->
LJID2 = setelement(1, LJID, ""),
case ?DICT:find(LJID2, StateData#state.affiliations) of
{ok, Affiliation} ->
Affiliation;
_ ->
LJID3 = jlib:jid_remove_resource(LJID2),
case ?DICT:find(LJID3, StateData#state.affiliations) of
{ok, Affiliation} -> {ok, Affiliation} ->
Affiliation; Affiliation;
_ -> _ ->
none none
end end
end
end
end
end,
case Res of
{A, _Reason} ->
A;
_ ->
Res
end. end.
set_role(JID, Role, StateData) -> set_role(JID, Role, StateData) ->
@ -1437,7 +1474,12 @@ items_with_role(SRole, StateData) ->
items_with_affiliation(SAffiliation, StateData) -> items_with_affiliation(SAffiliation, StateData) ->
lists:map( lists:map(
fun({JID, Affiliation}) -> fun({JID, {Affiliation, Reason}}) ->
{xmlelement, "item",
[{"affiliation", affiliation_to_list(Affiliation)},
{"jid", jlib:jid_to_string(JID)}],
[{xmlelement, "reason", [], [{xmlcdata, Reason}]}]};
({JID, Affiliation}) ->
{xmlelement, "item", {xmlelement, "item",
[{"affiliation", affiliation_to_list(Affiliation)}, [{"affiliation", affiliation_to_list(Affiliation)},
{"jid", jlib:jid_to_string(JID)}], {"jid", jlib:jid_to_string(JID)}],
@ -1465,7 +1507,12 @@ search_role(Role, StateData) ->
search_affiliation(Affiliation, StateData) -> search_affiliation(Affiliation, StateData) ->
lists:filter( lists:filter(
fun({_, A}) -> fun({_, A}) ->
case A of
{A1, _Reason} ->
Affiliation == A1;
_ ->
Affiliation == A Affiliation == A
end
end, ?DICT:to_list(StateData#state.affiliations)). end, ?DICT:to_list(StateData#state.affiliations)).
@ -1486,8 +1533,8 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
{JID, affiliation, outcast, Reason} -> {JID, affiliation, outcast, Reason} ->
catch send_kickban_presence( catch send_kickban_presence(
JID, Reason, "301", SD), JID, Reason, "301", SD),
set_affiliation( set_affiliation_and_reason(
JID, outcast, 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) ->
@ -1512,14 +1559,13 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
end end
) of ) of
{'EXIT', ErrReason} -> {'EXIT', ErrReason} ->
io:format("MUC ITEMS SET ERR: ~p~n", ?ERROR_MSG("MUC ITEMS SET ERR: ~p~n",
[ErrReason]), [ErrReason]),
SD; SD;
NSD -> NSD ->
NSD NSD
end end
end, StateData, Res), end, StateData, Res),
io:format("MUC SET: ~p~n", [Res]),
case (NSD#state.config)#config.persistent of case (NSD#state.config)#config.persistent of
true -> true ->
mod_muc:store_room(NSD#state.host, NSD#state.room, mod_muc:store_room(NSD#state.host, NSD#state.room,