mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
* src/mod_privacy.erl: Privacy rules support
* src/ejabberd_c2s.erl: Likewise * src/mod_roster.erl: Likewise SVN Revision: 128
This commit is contained in:
parent
f91e46ad8d
commit
d0f38de9e1
@ -1,3 +1,9 @@
|
|||||||
|
2003-08-03 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
|
* src/mod_privacy.erl: Privacy rules support
|
||||||
|
* src/ejabberd_c2s.erl: Likewise
|
||||||
|
* src/mod_roster.erl: Likewise
|
||||||
|
|
||||||
2003-07-27 Alexey Shchepin <alexey@sevcom.net>
|
2003-07-27 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/mod_pubsub/mod_pubsub.erl (create_new_node): Bugfix
|
* src/mod_pubsub/mod_pubsub.erl (create_new_node): Bugfix
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
{modules, [
|
{modules, [
|
||||||
{mod_register, []},
|
{mod_register, []},
|
||||||
{mod_roster, []},
|
{mod_roster, []},
|
||||||
|
{mod_privacy, []},
|
||||||
{mod_configure, []},
|
{mod_configure, []},
|
||||||
{mod_disco, []},
|
{mod_disco, []},
|
||||||
{mod_stats, []},
|
{mod_stats, []},
|
||||||
|
@ -52,7 +52,8 @@
|
|||||||
pres_i = ?SETS:new(),
|
pres_i = ?SETS:new(),
|
||||||
pres_last, pres_pri,
|
pres_last, pres_pri,
|
||||||
pres_timestamp,
|
pres_timestamp,
|
||||||
pres_invis = false}).
|
pres_invis = false,
|
||||||
|
privacy_list = none}).
|
||||||
|
|
||||||
%-define(DBGFSM, true).
|
%-define(DBGFSM, true).
|
||||||
|
|
||||||
@ -210,11 +211,17 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
|
|||||||
send_element(StateData, Res),
|
send_element(StateData, Res),
|
||||||
change_shaper(StateData, JID),
|
change_shaper(StateData, JID),
|
||||||
{Fs, Ts} = mod_roster:get_subscription_lists(U),
|
{Fs, Ts} = mod_roster:get_subscription_lists(U),
|
||||||
|
PrivList =
|
||||||
|
case catch mod_privacy:get_user_list(U) of
|
||||||
|
{'EXIT', _} -> none;
|
||||||
|
PL -> PL
|
||||||
|
end,
|
||||||
{next_state, session_established,
|
{next_state, session_established,
|
||||||
StateData#state{user = U,
|
StateData#state{user = U,
|
||||||
resource = R,
|
resource = R,
|
||||||
pres_f = ?SETS:from_list(Fs),
|
pres_f = ?SETS:from_list(Fs),
|
||||||
pres_t = ?SETS:from_list(Ts)}};
|
pres_t = ?SETS:from_list(Ts),
|
||||||
|
privacy_list = PrivList}};
|
||||||
_ ->
|
_ ->
|
||||||
Err = jlib:make_error_reply(
|
Err = jlib:make_error_reply(
|
||||||
El, ?ERR_FORBIDDEN),
|
El, ?ERR_FORBIDDEN),
|
||||||
@ -398,9 +405,15 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
|
|||||||
send_element(StateData, Res),
|
send_element(StateData, Res),
|
||||||
change_shaper(StateData, JID),
|
change_shaper(StateData, JID),
|
||||||
{Fs, Ts} = mod_roster:get_subscription_lists(U),
|
{Fs, Ts} = mod_roster:get_subscription_lists(U),
|
||||||
|
PrivList =
|
||||||
|
case catch mod_privacy:get_user_list(U) of
|
||||||
|
{'EXIT', _} -> none;
|
||||||
|
PL -> PL
|
||||||
|
end,
|
||||||
{next_state, session_established,
|
{next_state, session_established,
|
||||||
StateData#state{pres_f = ?SETS:from_list(Fs),
|
StateData#state{pres_f = ?SETS:from_list(Fs),
|
||||||
pres_t = ?SETS:from_list(Ts)}};
|
pres_t = ?SETS:from_list(Ts),
|
||||||
|
privacy_list = PrivList}};
|
||||||
_ ->
|
_ ->
|
||||||
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
|
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
|
||||||
send_element(StateData, Err),
|
send_element(StateData, Err),
|
||||||
@ -465,10 +478,27 @@ session_established({xmlstreamelement, El}, StateData) ->
|
|||||||
_ ->
|
_ ->
|
||||||
presence_track(FromJID, ToJID, El, StateData)
|
presence_track(FromJID, ToJID, El, StateData)
|
||||||
end;
|
end;
|
||||||
|
"iq" ->
|
||||||
|
case StateData#state.privacy_list of
|
||||||
|
none ->
|
||||||
|
ejabberd_router:route(FromJID, ToJID, El),
|
||||||
|
StateData;
|
||||||
|
PrivList ->
|
||||||
|
case jlib:iq_query_info(El) of
|
||||||
|
{iq, ID, Type, ?NS_PRIVACY = XMLNS, SubEl} = IQ ->
|
||||||
|
process_privacy_iq(
|
||||||
|
FromJID, ToJID, IQ, StateData);
|
||||||
_ ->
|
_ ->
|
||||||
ejabberd_router:route(FromJID, ToJID, El),
|
ejabberd_router:route(FromJID, ToJID, El),
|
||||||
StateData
|
StateData
|
||||||
end
|
end
|
||||||
|
end;
|
||||||
|
"message" ->
|
||||||
|
ejabberd_router:route(FromJID, ToJID, El),
|
||||||
|
StateData;
|
||||||
|
_ ->
|
||||||
|
StateData
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
{next_state, session_established, NewState};
|
{next_state, session_established, NewState};
|
||||||
|
|
||||||
@ -564,7 +594,7 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
{true, Attrs, StateData}
|
{true, Attrs, StateData}
|
||||||
end;
|
end;
|
||||||
"broadcast" ->
|
"broadcast" ->
|
||||||
?DEBUG("broadcast!!!!!!!!!!!~n~p~n", [Els]),
|
?DEBUG("broadcast~n~p~n", [Els]),
|
||||||
NewSt = case Els of
|
NewSt = case Els of
|
||||||
[{item, IJID, ISubscription}] ->
|
[{item, IJID, ISubscription}] ->
|
||||||
{false, Attrs,
|
{false, Attrs,
|
||||||
@ -572,6 +602,16 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
|||||||
StateData)};
|
StateData)};
|
||||||
[{exit, Reason}] ->
|
[{exit, Reason}] ->
|
||||||
{exit, Attrs, Reason};
|
{exit, Attrs, Reason};
|
||||||
|
[{privacy_list, PrivList}] ->
|
||||||
|
{false, Attrs,
|
||||||
|
case catch mod_privacy:updated_list(
|
||||||
|
StateData#state.privacy_list,
|
||||||
|
PrivList) of
|
||||||
|
{'EXIT', _} ->
|
||||||
|
{false, Attrs, StateData};
|
||||||
|
NewPL ->
|
||||||
|
StateData#state{privacy_list = NewPL}
|
||||||
|
end};
|
||||||
_ ->
|
_ ->
|
||||||
{false, Attrs, StateData}
|
{false, Attrs, StateData}
|
||||||
end;
|
end;
|
||||||
@ -979,3 +1019,42 @@ update_priority(El, StateData) ->
|
|||||||
StateData#state.resource,
|
StateData#state.resource,
|
||||||
Pri).
|
Pri).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
process_privacy_iq(From, To, {iq, ID, Type, XMLNS, SubEl} = IQ, StateData) ->
|
||||||
|
{Res, NewStateData} =
|
||||||
|
case Type of
|
||||||
|
get ->
|
||||||
|
case catch
|
||||||
|
mod_privacy:process_iq_get(
|
||||||
|
From, To, IQ,
|
||||||
|
StateData#state.privacy_list) of
|
||||||
|
{'EXIT', _} ->
|
||||||
|
{{error, ?ERR_FEATURE_NOT_IMPLEMENTED}, StateData};
|
||||||
|
R -> {R, StateData}
|
||||||
|
end;
|
||||||
|
set ->
|
||||||
|
case catch
|
||||||
|
mod_privacy:process_iq_set(
|
||||||
|
From, To, IQ) of
|
||||||
|
{'EXIT', _} ->
|
||||||
|
{{error, ?ERR_FEATURE_NOT_IMPLEMENTED}, StateData};
|
||||||
|
{result, R, NewPrivList} ->
|
||||||
|
{{result, R},
|
||||||
|
StateData#state{privacy_list = NewPrivList}};
|
||||||
|
R -> {R, StateData}
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
IQRes =
|
||||||
|
case Res of
|
||||||
|
{result, Result} ->
|
||||||
|
{iq, ID, result, XMLNS, Result};
|
||||||
|
{error, Error} ->
|
||||||
|
{iq, ID, error, XMLNS,
|
||||||
|
[SubEl, Error]}
|
||||||
|
end,
|
||||||
|
ejabberd_router:route(
|
||||||
|
To, From, jlib:iq_to_xml(IQRes)),
|
||||||
|
NewStateData.
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
in_subscription/3,
|
in_subscription/3,
|
||||||
out_subscription/3,
|
out_subscription/3,
|
||||||
set_items/2,
|
set_items/2,
|
||||||
remove_user/1]).
|
remove_user/1,
|
||||||
|
get_jid_info/2]).
|
||||||
|
|
||||||
-include_lib("mnemosyne/include/mnemosyne.hrl").
|
-include_lib("mnemosyne/include/mnemosyne.hrl").
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
@ -542,3 +543,18 @@ process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) ->
|
|||||||
end;
|
end;
|
||||||
process_item_attrs_ws(Item, []) ->
|
process_item_attrs_ws(Item, []) ->
|
||||||
Item.
|
Item.
|
||||||
|
|
||||||
|
|
||||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
|
|
||||||
|
get_jid_info(User, JID) ->
|
||||||
|
LUser = jlib:tolower(User),
|
||||||
|
LJID = jlib:jid_tolower(JID),
|
||||||
|
case catch mnesia:dirty_read(roster, {LUser, LJID}) of
|
||||||
|
[#roster{subscription = Subscription, groups = Groups}] ->
|
||||||
|
{Subscription, Groups};
|
||||||
|
_ ->
|
||||||
|
{none, []}
|
||||||
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user