mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
update pubsub_odbc patch
This commit is contained in:
parent
79648ce853
commit
fd828c3e9b
@ -60,11 +60,11 @@
|
||||
|
||||
%% exports for hooks
|
||||
-export([presence_probe/3,
|
||||
caps_update/3,
|
||||
in_subscription/6,
|
||||
out_subscription/4,
|
||||
on_user_offline/3,
|
||||
remove_user/2,
|
||||
feature_check_packet/6,
|
||||
disco_local_identity/5,
|
||||
disco_local_features/5,
|
||||
disco_local_items/5,
|
||||
@ -207,7 +207,7 @@ init([ServerHost, Opts]) ->
|
||||
ejabberd_hooks:add(anonymous_purge_hook, ServerHost, ?MODULE, remove_user, 50),
|
||||
case lists:member(?PEPNODE, Plugins) of
|
||||
true ->
|
||||
ejabberd_hooks:add(feature_check_packet, ServerHost, ?MODULE, feature_check_packet, 75),
|
||||
ejabberd_hooks:add(caps_update, ServerHost, ?MODULE, caps_update, 80),
|
||||
ejabberd_hooks:add(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75),
|
||||
ejabberd_hooks:add(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75),
|
||||
ejabberd_hooks:add(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75),
|
||||
@ -257,12 +257,17 @@ init_plugins(Host, ServerHost, Opts) ->
|
||||
Plugins = gen_mod:get_opt(plugins, Opts, [?STDNODE]),
|
||||
PepMapping = gen_mod:get_opt(pep_mapping, Opts, []),
|
||||
?DEBUG("** PEP Mapping : ~p~n",[PepMapping]),
|
||||
lists:foreach(fun(Name) ->
|
||||
?DEBUG("** init ~s plugin",[Name]),
|
||||
PluginsOK = lists:foldl(fun(Name, Acc) ->
|
||||
Plugin = list_to_atom(?PLUGIN_PREFIX ++ Name),
|
||||
Plugin:init(Host, ServerHost, Opts)
|
||||
end, Plugins),
|
||||
{Plugins, TreePlugin, PepMapping}.
|
||||
case catch apply(Plugin, init, [Host, ServerHost, Opts]) of
|
||||
{'EXIT', _Error} ->
|
||||
Acc;
|
||||
_ ->
|
||||
?DEBUG("** init ~s plugin",[Name]),
|
||||
[Name | Acc]
|
||||
end
|
||||
end, [], Plugins),
|
||||
{lists:reverse(PluginsOK), TreePlugin, PepMapping}.
|
||||
|
||||
terminate_plugins(Host, ServerHost, Plugins, TreePlugin) ->
|
||||
lists:foreach(fun(Name) ->
|
||||
@ -530,6 +535,10 @@ disco_items(Host, Node, From) ->
|
||||
%% presence hooks handling functions
|
||||
%%
|
||||
|
||||
caps_update(#jid{luser = U, lserver = S, lresource = R} = From, To, _Features) ->
|
||||
Pid = ejabberd_sm:get_session_pid(U, S, R),
|
||||
presence_probe(From, To, Pid).
|
||||
|
||||
presence_probe(#jid{luser = User, lserver = Server, lresource = Resource} = JID, JID, Pid) ->
|
||||
%%?DEBUG("presence probe self ~s@~s/~s ~s@~s/~s",[User,Server,Resource,element(2,JID),element(3,JID),element(4,JID)]),
|
||||
presence(Server, {presence, JID, Pid}),
|
||||
@ -573,13 +582,15 @@ out_subscription(User, Server, JID, subscribed) ->
|
||||
[] -> user_resources(PUser, PServer);
|
||||
_ -> [PResource]
|
||||
end,
|
||||
presence(Server, {presence, PUser, PServer, PResources, Owner});
|
||||
presence(Server, {presence, PUser, PServer, PResources, Owner}),
|
||||
true;
|
||||
out_subscription(_,_,_,_) ->
|
||||
ok.
|
||||
true.
|
||||
in_subscription(_, User, Server, Owner, unsubscribed, _) ->
|
||||
unsubscribe_user(jlib:make_jid(User, Server, ""), Owner);
|
||||
unsubscribe_user(jlib:make_jid(User, Server, ""), Owner),
|
||||
true;
|
||||
in_subscription(_, _, _, _, _, _) ->
|
||||
ok.
|
||||
true.
|
||||
|
||||
unsubscribe_user(Entity, Owner) ->
|
||||
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@ -698,7 +709,7 @@ terminate(_Reason, #state{host = Host,
|
||||
ejabberd_router:unregister_route(Host),
|
||||
case lists:member(?PEPNODE, Plugins) of
|
||||
true ->
|
||||
ejabberd_hooks:delete(feature_check_packet, ServerHost, ?MODULE, feature_check_packet, 75),
|
||||
ejabberd_hooks:delete(caps_update, ServerHost, ?MODULE, caps_update, 80),
|
||||
ejabberd_hooks:delete(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75),
|
||||
ejabberd_hooks:delete(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75),
|
||||
ejabberd_hooks:delete(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75),
|
||||
@ -1732,9 +1743,11 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
SubAttrs = case Subscription of
|
||||
{subscribed, SubId} ->
|
||||
[{"subscription", subscription_to_string(subscribed)},
|
||||
{"subid", SubId}];
|
||||
{"subid", SubId},
|
||||
{"node",Node}];
|
||||
Other ->
|
||||
[{"subscription", subscription_to_string(Other)}]
|
||||
[{"subscription", subscription_to_string(Other)},
|
||||
{"node", Node}]
|
||||
end,
|
||||
Fields =
|
||||
[{"jid", jlib:jid_to_string(Subscriber)} | SubAttrs],
|
||||
@ -2998,26 +3011,11 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, NodeId, Type, Nod
|
||||
%% set the from address on the notification to the bare JID of the account owner
|
||||
%% Also, add "replyto" if entity has presence subscription to the account owner
|
||||
%% See XEP-0163 1.1 section 4.3.1
|
||||
Sender = jlib:make_jid(LUser, LServer, ""),
|
||||
ReplyTo = jlib:jid_to_string(Publisher),
|
||||
StanzaToSend = add_extended_headers(Stanza, extended_headers([ReplyTo])),
|
||||
case catch ejabberd_c2s:get_subscribed(C2SPid) of
|
||||
Contacts when is_list(Contacts) ->
|
||||
lists:foreach(fun({U, S, _}) ->
|
||||
spawn(fun() ->
|
||||
case lists:member(S, ?MYHOSTS) of
|
||||
true ->
|
||||
lists:foreach(fun(To) ->
|
||||
ejabberd_router:route(Sender, jlib:make_jid(To), StanzaToSend)
|
||||
end, [{U, S, R} || R <- user_resources(U, S)]);
|
||||
false ->
|
||||
ejabberd_router:route(Sender, jlib:make_jid(U, S, ""), StanzaToSend)
|
||||
end
|
||||
end)
|
||||
end, Contacts);
|
||||
_ ->
|
||||
ok
|
||||
end;
|
||||
ejabberd_c2s:broadcast(C2SPid,
|
||||
{pep_message, binary_to_list(Node)++"+notify"},
|
||||
_Sender = jlib:make_jid(LUser, LServer, ""),
|
||||
_StanzaToSend = add_extended_headers(Stanza,
|
||||
_ReplyTo = extended_headers([jlib:jid_to_string(Publisher)])));
|
||||
_ ->
|
||||
?DEBUG("~p@~p has no session; can't deliver ~p to contacts", [LUser, LServer, BaseStanza])
|
||||
end;
|
||||
@ -3573,7 +3571,7 @@ tree_action(Host, Function, Args) ->
|
||||
node_call(Type, Function, Args) ->
|
||||
?DEBUG("node_call ~p ~p ~p",[Type, Function, Args]),
|
||||
Module = list_to_atom(?PLUGIN_PREFIX++Type),
|
||||
case catch apply(Module, Function, Args) of
|
||||
case apply(Module, Function, Args) of
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{'EXIT', {undef, Undefined}} ->
|
||||
@ -3736,59 +3734,6 @@ subid_shim(SubIDs) ->
|
||||
extended_headers(Jids) ->
|
||||
[{xmlelement, "address", [{"type", "replyto"}, {"jid", Jid}], []} || Jid <- Jids].
|
||||
|
||||
|
||||
feature_check_packet(allow, _User, Server, Pres,
|
||||
{#jid{lserver = LServer}, _To,
|
||||
{xmlelement, "message", MsgAttrs, _} = El}, in) ->
|
||||
Host = host(Server),
|
||||
case LServer of
|
||||
%% If the sender Server equals Host, the message comes from the Pubsub server
|
||||
Host ->
|
||||
allow;
|
||||
%% Else, the message comes from PEP
|
||||
_ ->
|
||||
case xml:get_subtag(El, "event") of
|
||||
{xmlelement, _, Attrs, _} = EventEl ->
|
||||
case xml:get_attr_s("xmlns", Attrs) of
|
||||
?NS_PUBSUB_EVENT ->
|
||||
case xml:get_attr_s("type", MsgAttrs) of
|
||||
"error" ->
|
||||
%% Filter error-repsonse of PEP message
|
||||
%% to avoid routing it to client
|
||||
deny;
|
||||
_ when Pres /= undefined ->
|
||||
%% Yes, sometimes Pres = undefined,
|
||||
%% very rare though.
|
||||
%% Seems like this is a bug: should
|
||||
%% be fixed in ejabberd_s2s.erl
|
||||
Feature = xml:get_path_s(
|
||||
EventEl, [{elem, "items"},
|
||||
{attr, "node"}]),
|
||||
case is_feature_supported(Pres, Feature) of
|
||||
true ->
|
||||
allow;
|
||||
false ->
|
||||
deny
|
||||
end;
|
||||
_ ->
|
||||
allow
|
||||
end;
|
||||
_ ->
|
||||
allow
|
||||
end;
|
||||
_ ->
|
||||
allow
|
||||
end
|
||||
end;
|
||||
feature_check_packet(Acc, _User, _Server, _Pres, _Packet, _Direction) ->
|
||||
Acc.
|
||||
|
||||
is_feature_supported({xmlelement, "presence", _, Els}, Feature) ->
|
||||
case mod_caps:read_caps(Els) of
|
||||
nothing -> false;
|
||||
Caps -> lists:member(Feature ++ "+notify", mod_caps:get_features(Caps))
|
||||
end.
|
||||
|
||||
on_user_offline(_, JID, _) ->
|
||||
{User, Server, Resource} = jlib:jid_tolower(JID),
|
||||
case ejabberd_sm:get_user_resources(User, Server) of
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2010-08-02 16:07:28.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2010-08-02 17:04:37.000000000 +0200
|
||||
--- mod_pubsub.erl 2010-12-07 13:54:26.000000000 +0100
|
||||
+++ mod_pubsub_odbc.erl 2010-12-07 13:59:56.000000000 +0100
|
||||
@@ -42,7 +42,7 @@
|
||||
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
|
||||
%%% XEP-0060 section 12.18.
|
||||
@ -49,7 +49,7 @@
|
||||
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
||||
State = #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
@@ -277,207 +275,14 @@
|
||||
@@ -282,207 +280,14 @@
|
||||
|
||||
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
||||
%% TODO, this call should be done plugin side
|
||||
@ -260,7 +260,7 @@
|
||||
send_loop(State) ->
|
||||
receive
|
||||
{presence, JID, Pid} ->
|
||||
@@ -488,17 +293,15 @@
|
||||
@@ -493,17 +298,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) ->
|
||||
@ -284,7 +284,7 @@
|
||||
true ->
|
||||
% resource not concerned about that subscription
|
||||
ok
|
||||
@@ -617,7 +420,8 @@
|
||||
@@ -622,7 +425,8 @@
|
||||
disco_identity(_Host, <<>>, _From) ->
|
||||
[{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []}];
|
||||
disco_identity(Host, Node, From) ->
|
||||
@ -294,7 +294,7 @@
|
||||
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
|
||||
{result, _} ->
|
||||
{result, [{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []},
|
||||
@@ -652,7 +456,8 @@
|
||||
@@ -657,7 +461,8 @@
|
||||
[?NS_PUBSUB
|
||||
| [?NS_PUBSUB++"#"++Feature || Feature <- features("pep")]];
|
||||
disco_features(Host, Node, From) ->
|
||||
@ -304,7 +304,7 @@
|
||||
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
|
||||
{result, _} ->
|
||||
{result, [?NS_PUBSUB
|
||||
@@ -677,7 +482,8 @@
|
||||
@@ -682,7 +487,8 @@
|
||||
Acc.
|
||||
|
||||
disco_items(Host, <<>>, From) ->
|
||||
@ -314,7 +314,7 @@
|
||||
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
|
||||
{result, _} ->
|
||||
[{xmlelement, "item",
|
||||
@@ -695,13 +501,14 @@
|
||||
@@ -700,13 +506,14 @@
|
||||
_ -> Acc
|
||||
end
|
||||
end,
|
||||
@ -331,7 +331,7 @@
|
||||
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
|
||||
{result, Items} ->
|
||||
{result, [{xmlelement, "item",
|
||||
@@ -781,10 +588,10 @@
|
||||
@@ -792,10 +599,10 @@
|
||||
lists:foreach(fun(PType) ->
|
||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
|
||||
lists:foreach(fun
|
||||
@ -344,7 +344,7 @@
|
||||
true ->
|
||||
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
||||
false ->
|
||||
@@ -952,7 +759,8 @@
|
||||
@@ -963,7 +770,8 @@
|
||||
sub_el = SubEl} = IQ ->
|
||||
{xmlelement, _, QAttrs, _} = SubEl,
|
||||
Node = xml:get_attr_s("node", QAttrs),
|
||||
@ -354,7 +354,7 @@
|
||||
{result, IQRes} ->
|
||||
jlib:iq_to_xml(
|
||||
IQ#iq{type = result,
|
||||
@@ -1065,7 +873,7 @@
|
||||
@@ -1076,7 +884,7 @@
|
||||
[] ->
|
||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||
_ ->
|
||||
@ -363,7 +363,7 @@
|
||||
{result, []} -> ["collection"];
|
||||
{result, _} -> ["leaf", "collection"];
|
||||
_ -> []
|
||||
@@ -1081,8 +889,9 @@
|
||||
@@ -1092,8 +900,9 @@
|
||||
[];
|
||||
true ->
|
||||
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
|
||||
@ -375,7 +375,7 @@
|
||||
end, features(Type))]
|
||||
end,
|
||||
%% TODO: add meta-data info (spec section 5.4)
|
||||
@@ -1111,8 +920,9 @@
|
||||
@@ -1122,8 +931,9 @@
|
||||
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
|
||||
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
|
||||
@ -387,7 +387,7 @@
|
||||
end, features(Host, Node))};
|
||||
<<?NS_COMMANDS>> ->
|
||||
command_disco_info(Host, Node, From);
|
||||
@@ -1122,7 +932,7 @@
|
||||
@@ -1133,7 +943,7 @@
|
||||
node_disco_info(Host, Node, From)
|
||||
end.
|
||||
|
||||
@ -396,7 +396,7 @@
|
||||
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
||||
Nodes when is_list(Nodes) ->
|
||||
{result, lists:map(
|
||||
@@ -1139,23 +949,24 @@
|
||||
@@ -1150,23 +960,24 @@
|
||||
Other ->
|
||||
Other
|
||||
end;
|
||||
@ -427,7 +427,7 @@
|
||||
end,
|
||||
Nodes = lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}, options = SubOptions}) ->
|
||||
@@ -1173,7 +984,7 @@
|
||||
@@ -1184,7 +995,7 @@
|
||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||
{xmlelement, "item", [{"jid", Host}, {"name", Name}], []}
|
||||
end, NodeItems),
|
||||
@ -436,7 +436,7 @@
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, Result}} -> {result, Result};
|
||||
@@ -1284,7 +1095,8 @@
|
||||
@@ -1295,7 +1106,8 @@
|
||||
(_, Acc) ->
|
||||
Acc
|
||||
end, [], xml:remove_cdata(Els)),
|
||||
@ -446,7 +446,7 @@
|
||||
{get, "subscriptions"} ->
|
||||
get_subscriptions(Host, Node, From, Plugins);
|
||||
{get, "affiliations"} ->
|
||||
@@ -1307,7 +1119,9 @@
|
||||
@@ -1318,7 +1130,9 @@
|
||||
|
||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||
{xmlelement, _, _, SubEls} = SubEl,
|
||||
@ -457,7 +457,7 @@
|
||||
case Action of
|
||||
[{xmlelement, Name, Attrs, Els}] ->
|
||||
Node = string_to_node(xml:get_attr_s("node", Attrs)),
|
||||
@@ -1437,7 +1251,8 @@
|
||||
@@ -1448,7 +1262,8 @@
|
||||
_ -> []
|
||||
end
|
||||
end,
|
||||
@ -467,7 +467,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1476,7 +1291,7 @@
|
||||
@@ -1487,7 +1302,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -476,7 +476,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
Stanza = {xmlelement, "message",
|
||||
[],
|
||||
@@ -1505,7 +1320,7 @@
|
||||
@@ -1516,7 +1331,7 @@
|
||||
[{xmlelement, "value", [], [{xmlcdata, "false"}]}]}]}]},
|
||||
lists:foreach(fun(Owner) ->
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(Owner), Stanza)
|
||||
@ -485,7 +485,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
{xmlelement, _Name, _Attrs, Els} = Packet,
|
||||
@@ -1569,8 +1384,8 @@
|
||||
@@ -1580,8 +1395,8 @@
|
||||
"true" -> true;
|
||||
_ -> false
|
||||
end,
|
||||
@ -496,7 +496,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1769,7 +1584,7 @@
|
||||
@@ -1780,7 +1595,7 @@
|
||||
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "create", nodeAttr(Node),
|
||||
[]}]}],
|
||||
@ -505,7 +505,7 @@
|
||||
{result, {NodeId, SubsByDepth, {Result, broadcast}}} ->
|
||||
broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth),
|
||||
case Result of
|
||||
@@ -1872,7 +1687,7 @@
|
||||
@@ -1883,7 +1698,7 @@
|
||||
%%<li>The node does not exist.</li>
|
||||
%%</ul>
|
||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
@ -514,7 +514,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -1880,7 +1695,7 @@
|
||||
@@ -1891,7 +1706,7 @@
|
||||
error -> {"", "", ""};
|
||||
J -> jlib:jid_tolower(J)
|
||||
end,
|
||||
@ -523,7 +523,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1889,6 +1704,7 @@
|
||||
@@ -1900,6 +1715,7 @@
|
||||
AccessModel = get_option(Options, access_model),
|
||||
SendLast = get_option(Options, send_last_published_item),
|
||||
AllowedGroups = get_option(Options, roster_groups_allowed, []),
|
||||
@ -531,7 +531,7 @@
|
||||
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups),
|
||||
if
|
||||
not SubscribeFeature ->
|
||||
@@ -2218,7 +2034,7 @@
|
||||
@@ -2231,7 +2047,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.
|
||||
@ -540,7 +540,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2232,12 +2048,13 @@
|
||||
@@ -2245,12 +2061,13 @@
|
||||
{error, Error} ->
|
||||
{error, Error};
|
||||
_ ->
|
||||
@ -555,7 +555,7 @@
|
||||
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
|
||||
if
|
||||
not RetreiveFeature ->
|
||||
@@ -2250,11 +2067,11 @@
|
||||
@@ -2263,11 +2080,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -569,7 +569,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2267,7 +2084,8 @@
|
||||
@@ -2280,7 +2097,8 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
@ -579,7 +579,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2289,10 +2107,15 @@
|
||||
@@ -2302,10 +2120,15 @@
|
||||
Error -> Error
|
||||
end.
|
||||
get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
|
||||
@ -596,7 +596,7 @@
|
||||
|
||||
|
||||
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
|
||||
@@ -2305,16 +2128,27 @@
|
||||
@@ -2318,16 +2141,27 @@
|
||||
%% @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) ->
|
||||
@ -630,7 +630,7 @@
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2440,7 +2274,8 @@
|
||||
@@ -2453,7 +2287,8 @@
|
||||
error ->
|
||||
{error, ?ERR_BAD_REQUEST};
|
||||
_ ->
|
||||
@ -640,7 +640,7 @@
|
||||
case lists:member(Owner, Owners) of
|
||||
true ->
|
||||
OwnerJID = jlib:make_jid(Owner),
|
||||
@@ -2450,24 +2285,7 @@
|
||||
@@ -2463,24 +2298,7 @@
|
||||
end,
|
||||
lists:foreach(
|
||||
fun({JID, Affiliation}) ->
|
||||
@ -666,7 +666,7 @@
|
||||
end, FilteredEntities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2520,11 +2338,11 @@
|
||||
@@ -2533,11 +2351,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -680,7 +680,7 @@
|
||||
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
||||
{"subid", SubID}|nodeAttr(Node)],
|
||||
[XdataEl]},
|
||||
@@ -2550,7 +2368,7 @@
|
||||
@@ -2563,7 +2381,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -689,7 +689,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2579,7 +2397,7 @@
|
||||
@@ -2592,7 +2410,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -698,7 +698,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2747,8 +2565,8 @@
|
||||
@@ -2760,8 +2578,8 @@
|
||||
{"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza)
|
||||
end,
|
||||
@ -709,7 +709,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3103,7 +2921,7 @@
|
||||
@@ -3116,7 +2934,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -718,7 +718,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3117,9 +2935,9 @@
|
||||
@@ -3130,9 +2948,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -730,7 +730,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3323,6 +3141,30 @@
|
||||
@@ -3321,6 +3139,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -761,7 +761,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3719,7 +3561,13 @@
|
||||
@@ -3717,7 +3559,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -776,7 +776,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3739,13 +3587,13 @@
|
||||
@@ -3737,13 +3585,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -792,7 +792,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3757,13 +3605,19 @@
|
||||
@@ -3755,13 +3603,19 @@
|
||||
Error
|
||||
end
|
||||
end, Trans).
|
||||
@ -816,7 +816,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3771,6 +3625,15 @@
|
||||
@@ -3769,6 +3623,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@ -832,7 +832,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@@ -3779,6 +3642,17 @@
|
||||
@@ -3777,6 +3640,17 @@
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user