mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
pubsub now is sync with last trunk
SVN Revision: 2546
This commit is contained in:
parent
bb08207569
commit
f5091aa1ae
@ -105,7 +105,8 @@
|
||||
string_to_subscription/1,
|
||||
string_to_affiliation/1,
|
||||
extended_error/2,
|
||||
extended_error/3
|
||||
extended_error/3,
|
||||
rename_default_nodeplugin/0
|
||||
]).
|
||||
|
||||
%% API and gen_server callbacks
|
||||
@ -2720,7 +2721,7 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
||||
{error, 'bad-request'};
|
||||
_ ->
|
||||
Notify = fun(JID, Sub, _SubId) ->
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT,
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT,
|
||||
name = 'message',
|
||||
children =
|
||||
[#xmlel{ns = ?NS_PUBSUB,
|
||||
@ -2730,7 +2731,6 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
||||
name = 'subscription',
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)),
|
||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||
|
||||
ejabberd_router ! {route, service_jid(Host), JID, Stanza}
|
||||
end,
|
||||
Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->
|
||||
|
@ -2551,7 +2551,7 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
||||
{error, 'bad-request'};
|
||||
_ ->
|
||||
Notify = fun(JID, Sub, _SubId) ->
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT,
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT,
|
||||
name = 'message',
|
||||
children =
|
||||
[#xmlel{ns = ?NS_PUBSUB,
|
||||
@ -2561,7 +2561,6 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
||||
name = 'subscription',
|
||||
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)),
|
||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||
|
||||
ejabberd_router ! {route, service_jid(Host), JID, Stanza}
|
||||
end,
|
||||
Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2009-08-25 17:29:57.000000000 -0300
|
||||
+++ mod_pubsub_odbc.erl 2009-08-26 12:07:05.000000000 -0300
|
||||
--- mod_pubsub.erl 2009-08-27 10:43:45.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2009-08-27 10:47:31.000000000 +0200
|
||||
@@ -45,7 +45,7 @@
|
||||
%%% TODO
|
||||
%%% plugin: generate Reply (do not use broadcast atom anymore)
|
||||
@ -22,17 +22,16 @@
|
||||
|
||||
%% exports for hooks
|
||||
-export([presence_probe/3,
|
||||
@@ -105,7 +105,8 @@
|
||||
string_to_subscription/1,
|
||||
@@ -106,7 +106,7 @@
|
||||
string_to_affiliation/1,
|
||||
extended_error/2,
|
||||
- extended_error/3
|
||||
+ extended_error/3,
|
||||
extended_error/3,
|
||||
- rename_default_nodeplugin/0
|
||||
+ escape/1
|
||||
]).
|
||||
|
||||
%% API and gen_server callbacks
|
||||
@@ -124,7 +125,7 @@
|
||||
@@ -125,7 +125,7 @@
|
||||
-export([send_loop/1
|
||||
]).
|
||||
|
||||
@ -41,7 +40,7 @@
|
||||
-define(PLUGIN_PREFIX, "node_").
|
||||
-define(TREE_PREFIX, "nodetree_").
|
||||
|
||||
@@ -221,8 +222,6 @@
|
||||
@@ -222,8 +222,6 @@
|
||||
ok
|
||||
end,
|
||||
ejabberd_router:register_route(Host),
|
||||
@ -50,7 +49,7 @@
|
||||
init_nodes(Host, ServerHost),
|
||||
State = #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
@@ -277,177 +276,7 @@
|
||||
@@ -278,177 +276,7 @@
|
||||
create_node(Host, ServerHost, ["home", ServerHost], service_jid(Host), "hometree"),
|
||||
ok.
|
||||
|
||||
@ -228,7 +227,7 @@
|
||||
|
||||
send_queue(State, Msg) ->
|
||||
Pid = State#state.send_loop,
|
||||
@@ -471,17 +300,15 @@
|
||||
@@ -472,17 +300,15 @@
|
||||
%% for each node From is subscribed to
|
||||
%% and if the node is so configured, send the last published item to From
|
||||
lists:foreach(fun(PType) ->
|
||||
@ -252,7 +251,7 @@
|
||||
true ->
|
||||
% resource not concerned about that subscription
|
||||
ok
|
||||
@@ -808,10 +635,10 @@
|
||||
@@ -809,10 +635,10 @@
|
||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
||||
lists:foreach(fun
|
||||
({Node, subscribed, _, JID}) ->
|
||||
@ -265,7 +264,7 @@
|
||||
true ->
|
||||
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
||||
false ->
|
||||
@@ -929,11 +756,12 @@
|
||||
@@ -930,11 +756,12 @@
|
||||
end,
|
||||
ejabberd_router:route(To, From, Res);
|
||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||
@ -280,7 +279,7 @@
|
||||
{result, IQRes} ->
|
||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
||||
name = 'query', attrs = QAttrs,
|
||||
@@ -1036,7 +864,7 @@
|
||||
@@ -1037,7 +864,7 @@
|
||||
[] ->
|
||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||
_ ->
|
||||
@ -289,7 +288,7 @@
|
||||
{result, []} -> ["collection"];
|
||||
{result, _} -> ["leaf", "collection"];
|
||||
_ -> []
|
||||
@@ -1052,8 +880,9 @@
|
||||
@@ -1053,8 +880,9 @@
|
||||
[];
|
||||
true ->
|
||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||
@ -301,7 +300,7 @@
|
||||
end, features(Type))]
|
||||
end,
|
||||
%% TODO: add meta-data info (spec section 5.4)
|
||||
@@ -1081,14 +910,15 @@
|
||||
@@ -1082,14 +910,15 @@
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]},
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||
@ -320,7 +319,7 @@
|
||||
{result, lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||
SN = node_to_string(SubNode),
|
||||
@@ -1098,7 +928,7 @@
|
||||
@@ -1099,7 +928,7 @@
|
||||
?XMLATTR('node', SN),
|
||||
?XMLATTR('name', RN)]}
|
||||
end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
||||
@ -329,7 +328,7 @@
|
||||
case string:tokens(Item, "!") of
|
||||
[_SNode, _ItemID] ->
|
||||
{result, []};
|
||||
@@ -1110,9 +940,9 @@
|
||||
@@ -1111,9 +940,9 @@
|
||||
%% TODO That is, remove name attribute (or node?, please check for 2.1)
|
||||
Action =
|
||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
@ -341,7 +340,7 @@
|
||||
end,
|
||||
Nodes = lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||
@@ -1128,7 +958,7 @@
|
||||
@@ -1129,7 +958,7 @@
|
||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('node', SN),
|
||||
?XMLATTR('name', Name)]}
|
||||
end, NodeItems),
|
||||
@ -350,7 +349,7 @@
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, Result}} -> {result, Result};
|
||||
@@ -1267,7 +1097,8 @@
|
||||
@@ -1268,7 +1097,8 @@
|
||||
(_, Acc) ->
|
||||
Acc
|
||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||
@ -360,7 +359,7 @@
|
||||
{get, 'subscriptions'} ->
|
||||
get_subscriptions(Host, Node, From, Plugins);
|
||||
{get, 'affiliations'} ->
|
||||
@@ -1289,8 +1120,11 @@
|
||||
@@ -1290,8 +1120,11 @@
|
||||
end.
|
||||
|
||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||
@ -374,7 +373,7 @@
|
||||
case Action of
|
||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||
Node = case Host of
|
||||
@@ -1420,7 +1254,8 @@
|
||||
@@ -1421,7 +1254,8 @@
|
||||
_ -> []
|
||||
end
|
||||
end,
|
||||
@ -384,7 +383,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1466,7 +1301,7 @@
|
||||
@@ -1467,7 +1301,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -393,7 +392,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
{U, S, R} = Subscriber,
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||
@@ -1496,7 +1331,7 @@
|
||||
@@ -1497,7 +1331,7 @@
|
||||
lists:foreach(fun(Owner) ->
|
||||
{U, S, R} = Owner,
|
||||
ejabberd_router ! {route, service_jid(Host), exmpp_jid:make(U, S, R), Stanza}
|
||||
@ -402,7 +401,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
Els = Packet#xmlel.children,
|
||||
@@ -1559,8 +1394,8 @@
|
||||
@@ -1560,8 +1394,8 @@
|
||||
"true" -> true;
|
||||
_ -> false
|
||||
end,
|
||||
@ -413,7 +412,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1750,7 +1585,7 @@
|
||||
@@ -1751,7 +1585,7 @@
|
||||
end,
|
||||
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
||||
@ -422,7 +421,7 @@
|
||||
{result, {Result, broadcast}} ->
|
||||
%%Lang = "en", %% TODO: fix
|
||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@@ -1866,7 +1701,7 @@
|
||||
@@ -1867,7 +1701,7 @@
|
||||
{undefined, undefined, undefined}
|
||||
end,
|
||||
SubId = uniqid(),
|
||||
@ -431,7 +430,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1885,9 +1720,13 @@
|
||||
@@ -1886,9 +1720,13 @@
|
||||
{"", "", ""} ->
|
||||
{false, false};
|
||||
_ ->
|
||||
@ -448,7 +447,7 @@
|
||||
end
|
||||
end,
|
||||
if
|
||||
@@ -2212,7 +2051,7 @@
|
||||
@@ -2213,7 +2051,7 @@
|
||||
%% <p>The permission are not checked in this function.</p>
|
||||
%% @todo We probably need to check that the user doing the query has the right
|
||||
%% to read the items.
|
||||
@ -457,7 +456,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> ?MAXITEMS;
|
||||
@@ -2251,11 +2090,11 @@
|
||||
@@ -2252,11 +2090,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -471,7 +470,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2268,7 +2107,7 @@
|
||||
@@ -2269,7 +2107,7 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
||||
@ -480,7 +479,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2300,16 +2139,25 @@
|
||||
@@ -2301,16 +2139,25 @@
|
||||
%% @doc <p>Resend the items of a node to the user.</p>
|
||||
%% @todo use cache-last-item feature
|
||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||
@ -513,7 +512,7 @@
|
||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2430,29 +2278,12 @@
|
||||
@@ -2431,29 +2278,12 @@
|
||||
error ->
|
||||
{error, 'bad-request'};
|
||||
_ ->
|
||||
@ -546,8 +545,8 @@
|
||||
end, Entities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2733,8 +2564,8 @@
|
||||
|
||||
@@ -2733,8 +2563,8 @@
|
||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||
ejabberd_router ! {route, service_jid(Host), JID, Stanza}
|
||||
end,
|
||||
- Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->
|
||||
@ -557,7 +556,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3237,6 +3068,30 @@
|
||||
@@ -3237,6 +3067,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -588,7 +587,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3613,7 +3468,13 @@
|
||||
@@ -3613,7 +3467,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -603,7 +602,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3633,13 +3494,13 @@
|
||||
@@ -3633,13 +3493,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -619,7 +618,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3652,8 +3513,15 @@
|
||||
@@ -3652,8 +3512,15 @@
|
||||
end
|
||||
end, Trans).
|
||||
|
||||
@ -637,7 +636,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3661,6 +3529,15 @@
|
||||
@@ -3661,6 +3528,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@ -653,7 +652,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@@ -3669,6 +3546,16 @@
|
||||
@@ -3669,6 +3545,16 @@
|
||||
{error, 'internal-server-error'}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user