mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Send last published PEP event now checks the correct peer caps (EJAB-491)
SVN Revision: 1143
This commit is contained in:
parent
7672515e76
commit
b3bf437dd1
@ -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>
|
||||
|
||||
* src/mod_muc/mod_muc_room.erl: MUC kicks a participant if sends a
|
||||
|
@ -1403,7 +1403,11 @@ process_presence_probe(From, To, StateData) ->
|
||||
deny ->
|
||||
ok;
|
||||
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)
|
||||
end;
|
||||
Cond2 ->
|
||||
|
@ -396,9 +396,9 @@ disco_sm_items(Acc, _From, To, Node, _Lang) ->
|
||||
%% 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),
|
||||
gen_server:cast(Proc, {presence, From, To, Packet}).
|
||||
gen_server:cast(Proc, {presence, From, To, Caps}).
|
||||
|
||||
%% -------
|
||||
%% user remove hook handling function
|
||||
@ -437,9 +437,9 @@ handle_call(stop, _From, State) ->
|
||||
%% Description: Handling cast messages
|
||||
%%--------------------------------------------------------------------
|
||||
%% @private
|
||||
handle_cast({presence, From, To, Packet}, State) ->
|
||||
handle_cast({presence, From, To, Caps}, State) ->
|
||||
%% A new resource is available. send last published items
|
||||
JID = jlib:jid_tolower(From),
|
||||
LFrom = jlib:jid_tolower(From),
|
||||
Host = State#state.host,
|
||||
ServerHost = State#state.server_host,
|
||||
if From == To ->
|
||||
@ -453,7 +453,7 @@ handle_cast({presence, From, To, Packet}, State) ->
|
||||
#pubsub_node{options = Options} ->
|
||||
case get_option(Options, send_last_published_item) of
|
||||
on_sub_and_presence ->
|
||||
send_last_item(Host, Node, JID);
|
||||
send_last_item(Host, Node, LFrom);
|
||||
_ ->
|
||||
ok
|
||||
end;
|
||||
@ -468,8 +468,8 @@ handle_cast({presence, From, To, Packet}, State) ->
|
||||
ok
|
||||
end,
|
||||
%% 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)),
|
||||
Caps = mod_caps:read_caps(element(4, Packet)),
|
||||
lists:foreach(fun(#pubsub_node{nodeid = {_, Node}, options = Options}) ->
|
||||
case get_option(Options, send_last_published_item) of
|
||||
on_sub_and_presence ->
|
||||
@ -482,10 +482,11 @@ handle_cast({presence, From, To, Packet}, State) ->
|
||||
authorize -> false; % likewise
|
||||
roster ->
|
||||
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,
|
||||
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 ->
|
||||
ok
|
||||
end;
|
||||
|
@ -136,18 +136,18 @@ create_node(Key, Node, Type, Owner, Options) ->
|
||||
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
case mnesia:read({pubsub_node, {Key, Node}}) of
|
||||
[] ->
|
||||
Parent = lists:sublist(Node, length(Node) - 1),
|
||||
ParentExists =
|
||||
{ParentNode, ParentExists} =
|
||||
case Key of
|
||||
{_U, _S, _R} ->
|
||||
%% This is special case for PEP handling
|
||||
%% PEP does not uses hierarchy
|
||||
true;
|
||||
{[], true};
|
||||
_ ->
|
||||
Parent = lists:sublist(Node, length(Node) - 1),
|
||||
(Parent == []) orelse
|
||||
case mnesia:read({pubsub_node, {Key, Parent}}) of
|
||||
[] -> false;
|
||||
_ -> true
|
||||
[] -> {Parent, false};
|
||||
_ -> {Parent, true}
|
||||
end
|
||||
end,
|
||||
case ParentExists of
|
||||
@ -155,7 +155,7 @@ create_node(Key, Node, Type, Owner, Options) ->
|
||||
%% Service requires registration
|
||||
%%{error, ?ERR_REGISTRATION_REQUIRED};
|
||||
mnesia:write(#pubsub_node{nodeid = {Key, Node},
|
||||
parentid = {Key, Parent},
|
||||
parentid = {Key, ParentNode},
|
||||
type = Type,
|
||||
owners = [OwnerKey],
|
||||
options = Options});
|
||||
|
Loading…
Reference in New Issue
Block a user