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

Send last published PEP event now checks the correct peer caps (EJAB-491)

SVN Revision: 1143
This commit is contained in:
Christophe Romain 2008-01-10 15:02:54 +00:00
parent 7672515e76
commit b3bf437dd1
4 changed files with 28 additions and 15 deletions

View File

@ -1,3 +1,11 @@
2008-01-10 Christophe Romain <christophe.romain@process-one.net>
* src/mod_pubsub/nodetree_default: Force PEP parent node to be []
* src/mod_pubsub/mod_pubsub.erl: Send last published PEP event now checks
the correct peer caps (EJAB-491)
* src/ejabberd_c2s.erl: Likewise
2008-01-09 Badlop <badlop@process-one.net> 2008-01-09 Badlop <badlop@process-one.net>
* src/mod_muc/mod_muc_room.erl: MUC kicks a participant if sends a * src/mod_muc/mod_muc_room.erl: MUC kicks a participant if sends a

View File

@ -1403,7 +1403,11 @@ process_presence_probe(From, To, StateData) ->
deny -> deny ->
ok; ok;
allow -> allow ->
ejabberd_hooks:run(presence_probe_hook, StateData#state.server, [From, To, Packet]), Caps = case ?DICT:find(jlib:jid_tolower(To), StateData#state.pres_available) of
{ok, Value} -> Value;
_ -> mod_caps:read_caps(element(4, Packet)) % This is From=To case, so we can read Caps from Packet
end,
ejabberd_hooks:run(presence_probe_hook, StateData#state.server, [From, To, Caps]),
ejabberd_router:route(To, From, Packet) ejabberd_router:route(To, From, Packet)
end; end;
Cond2 -> Cond2 ->

View File

@ -396,9 +396,9 @@ disco_sm_items(Acc, _From, To, Node, _Lang) ->
%% presence hooks handling functions %% presence hooks handling functions
%% %%
presence_probe(#jid{lserver = Host} = From, To, Packet) -> presence_probe(#jid{lserver = Host} = From, To, Caps) ->
Proc = gen_mod:get_module_proc(Host, ?PROCNAME), Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
gen_server:cast(Proc, {presence, From, To, Packet}). gen_server:cast(Proc, {presence, From, To, Caps}).
%% ------- %% -------
%% user remove hook handling function %% user remove hook handling function
@ -437,9 +437,9 @@ handle_call(stop, _From, State) ->
%% Description: Handling cast messages %% Description: Handling cast messages
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @private %% @private
handle_cast({presence, From, To, Packet}, State) -> handle_cast({presence, From, To, Caps}, State) ->
%% A new resource is available. send last published items %% A new resource is available. send last published items
JID = jlib:jid_tolower(From), LFrom = jlib:jid_tolower(From),
Host = State#state.host, Host = State#state.host,
ServerHost = State#state.server_host, ServerHost = State#state.server_host,
if From == To -> if From == To ->
@ -453,7 +453,7 @@ handle_cast({presence, From, To, Packet}, State) ->
#pubsub_node{options = Options} -> #pubsub_node{options = Options} ->
case get_option(Options, send_last_published_item) of case get_option(Options, send_last_published_item) of
on_sub_and_presence -> on_sub_and_presence ->
send_last_item(Host, Node, JID); send_last_item(Host, Node, LFrom);
_ -> _ ->
ok ok
end; end;
@ -468,8 +468,8 @@ handle_cast({presence, From, To, Packet}, State) ->
ok ok
end, end,
%% and send to From last PEP events published by To %% and send to From last PEP events published by To
?DEBUG("got presence probe from ~s to ~s",[jlib:jid_to_string(From),jlib:jid_to_string(To)]),
PepKey = jlib:jid_tolower(jlib:jid_remove_resource(To)), PepKey = jlib:jid_tolower(jlib:jid_remove_resource(To)),
Caps = mod_caps:read_caps(element(4, Packet)),
lists:foreach(fun(#pubsub_node{nodeid = {_, Node}, options = Options}) -> lists:foreach(fun(#pubsub_node{nodeid = {_, Node}, options = Options}) ->
case get_option(Options, send_last_published_item) of case get_option(Options, send_last_published_item) of
on_sub_and_presence -> on_sub_and_presence ->
@ -482,10 +482,11 @@ handle_cast({presence, From, To, Packet}, State) ->
authorize -> false; % likewise authorize -> false; % likewise
roster -> roster ->
Grps = get_option(Options, roster_groups_allowed), Grps = get_option(Options, roster_groups_allowed),
element(2, get_roster_info(To#jid.luser, To#jid.lserver, JID, Grps)) element(2, get_roster_info(To#jid.luser, To#jid.lserver, LFrom, Grps))
end, end,
if Subscribed -> if Subscribed ->
send_last_item(PepKey, Node, JID); ?DEBUG("send ~s's ~s event to ~s",[jlib:jid_to_string(PepKey),Node,jlib:jid_to_string(From)]),
send_last_item(PepKey, Node, LFrom);
true -> true ->
ok ok
end; end;

View File

@ -136,18 +136,18 @@ create_node(Key, Node, Type, Owner, Options) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
case mnesia:read({pubsub_node, {Key, Node}}) of case mnesia:read({pubsub_node, {Key, Node}}) of
[] -> [] ->
Parent = lists:sublist(Node, length(Node) - 1), {ParentNode, ParentExists} =
ParentExists =
case Key of case Key of
{_U, _S, _R} -> {_U, _S, _R} ->
%% This is special case for PEP handling %% This is special case for PEP handling
%% PEP does not uses hierarchy %% PEP does not uses hierarchy
true; {[], true};
_ -> _ ->
Parent = lists:sublist(Node, length(Node) - 1),
(Parent == []) orelse (Parent == []) orelse
case mnesia:read({pubsub_node, {Key, Parent}}) of case mnesia:read({pubsub_node, {Key, Parent}}) of
[] -> false; [] -> {Parent, false};
_ -> true _ -> {Parent, true}
end end
end, end,
case ParentExists of case ParentExists of
@ -155,7 +155,7 @@ create_node(Key, Node, Type, Owner, Options) ->
%% Service requires registration %% Service requires registration
%%{error, ?ERR_REGISTRATION_REQUIRED}; %%{error, ?ERR_REGISTRATION_REQUIRED};
mnesia:write(#pubsub_node{nodeid = {Key, Node}, mnesia:write(#pubsub_node{nodeid = {Key, Node},
parentid = {Key, Parent}, parentid = {Key, ParentNode},
type = Type, type = Type,
owners = [OwnerKey], owners = [OwnerKey],
options = Options}); options = Options});