25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

pubsub identity and database update bugfix

SVN Revision: 1285
This commit is contained in:
Christophe Romain 2008-04-10 14:11:06 +00:00
parent bbf90da6d0
commit 367610dd38
3 changed files with 43 additions and 30 deletions

View File

@ -1,6 +1,12 @@
2008-04-10 Christophe Romain <christophe.romain@process-one.net>
* src/mod_pubsub/mod_pubsub.erl: fix identity and database update
bugfix
* src/mod_pubsub/nodetree_default.erl: Likewise
2008-04-10 Mickael Remond <mremond@process-one.net> 2008-04-10 Mickael Remond <mremond@process-one.net>
*src/ejabberd_c2s.erl: Uniform default value for empty privacy * src/ejabberd_c2s.erl: Uniform default value for empty privacy
list. Fixes (EJAB-603). list. Fixes (EJAB-603).
2008-04-08 Badlop <badlop@process-one.net> 2008-04-08 Badlop <badlop@process-one.net>

View File

@ -232,7 +232,7 @@ init_nodes(Host, ServerHost, ServedHosts) ->
lists:foreach( lists:foreach(
fun(H) -> fun(H) ->
create_node(Host, ServerHost, ["home", H], service_jid(Host), ?STDNODE) create_node(Host, ServerHost, ["home", H], service_jid(Host), ?STDNODE)
end, [ServerHost | ServedHosts]), end, lists:usort([ServerHost | ServedHosts])),
ok. ok.
update_database(Host) -> update_database(Host) ->
@ -306,7 +306,7 @@ update_database(Host) ->
identity(Host) -> identity(Host) ->
Identity = case lists:member(?PEPNODE, plugins(Host)) of Identity = case lists:member(?PEPNODE, plugins(Host)) of
true -> [{"category", "pubsub"}, {"type", "pep"}]; true -> [{"category", "pubsub"}, {"type", "pep"}];
false -> [{"category", "pubsub"}] false -> [{"category", "pubsub"}, {"type", "service"}]
end, end,
{xmlelement, "identity", Identity, []}. {xmlelement, "identity", Identity, []}.
@ -2280,38 +2280,44 @@ broadcast_by_caps({LUser, LServer, LResource}, Node, _Type, Stanza) ->
[R|_] -> [R|_] ->
R; R;
[] -> [] ->
?ERROR_MSG("~p@~p is offline; can't deliver ~p to contacts", [LUser, LServer, Stanza]),
"" ""
end; end;
_ -> _ ->
LResource LResource
end, end,
case ejabberd_sm:get_session_pid(LUser, LServer, SenderResource) of case SenderResource of
C2SPid when is_pid(C2SPid) -> "" ->
%% set the from address on the notification to the bare JID of the account owner ?DEBUG("~p@~p is offline; can't deliver ~p to contacts", [LUser, LServer, Stanza]),
%% Also, add "replyto" if entity has presence subscription to the account owner ok;
%% See XEP-0163 1.1 section 4.3.1 _ ->
Sender = jlib:make_jid(LUser, LServer, ""), case ejabberd_sm:get_session_pid(LUser, LServer, SenderResource) of
%%ReplyTo = jlib:make_jid(LUser, LServer, SenderResource), % This has to be used C2SPid when is_pid(C2SPid) ->
case catch ejabberd_c2s:get_subscribed_and_online(C2SPid) of %% set the from address on the notification to the bare JID of the account owner
ContactsWithCaps when is_list(ContactsWithCaps) -> %% Also, add "replyto" if entity has presence subscription to the account owner
?DEBUG("found contacts with caps: ~p", [ContactsWithCaps]), %% See XEP-0163 1.1 section 4.3.1
lists:foreach( Sender = jlib:make_jid(LUser, LServer, ""),
fun({JID, Caps}) -> %%ReplyTo = jlib:make_jid(LUser, LServer, SenderResource), % This has to be used
case is_caps_notify(LServer, Node, Caps) of case catch ejabberd_c2s:get_subscribed_and_online(C2SPid) of
true -> ContactsWithCaps when is_list(ContactsWithCaps) ->
To = jlib:make_jid(JID), ?DEBUG("found contacts with caps: ~p", [ContactsWithCaps]),
ejabberd_router ! {route, Sender, To, Stanza}; lists:foreach(
false -> fun({JID, Caps}) ->
ok case is_caps_notify(LServer, Node, Caps) of
end true ->
end, ContactsWithCaps); To = jlib:make_jid(JID),
_ -> ejabberd_router ! {route, Sender, To, Stanza};
ok false ->
end, ok
ok; end
_ -> end, ContactsWithCaps);
ok _ ->
ok
end,
ok;
_ ->
?DEBUG("~p@~p has no session; can't deliver ~p to contacts", [LUser, LServer, Stanza]),
ok
end
end; end;
broadcast_by_caps(_, _, _, _) -> broadcast_by_caps(_, _, _, _) ->
ok. ok.

View File

@ -74,6 +74,7 @@ init(_Host, _ServerHost, _Opts) ->
{index, [type,parentid]}]), {index, [type,parentid]}]),
NodesFields = record_info(fields, pubsub_node), NodesFields = record_info(fields, pubsub_node),
case mnesia:table_info(pubsub_node, attributes) of case mnesia:table_info(pubsub_node, attributes) of
[host_node, host_parent, info] -> ok; % old schema, updated later by pubsub
NodesFields -> ok; NodesFields -> ok;
_ -> mnesia:transform_table(pubsub_node, ignore, NodesFields) _ -> mnesia:transform_table(pubsub_node, ignore, NodesFields)
end, end,