25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-30 16:36:29 +01:00

Fix some errors when porting from mod_pubsub.erl (thanks to Karim Gemayel)

This commit is contained in:
Badlop 2010-12-07 19:36:25 +01:00
parent 74f86bef6a
commit d448b6c955
2 changed files with 66 additions and 51 deletions

View File

@ -1153,8 +1153,8 @@ node_disco_info(Host, NodeId, From) ->
(T) -> #xmlel{ns = ?NS_DISCO_INFO, (T) -> #xmlel{ns = ?NS_DISCO_INFO,
name = 'feature', name = 'feature',
attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++T))]} attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++T))]}
end, features(Plugin)]} end, features(Plugin))]}
|| Type <- features(Plugin)]]} %%|| Type <- features(Plugin)]]}
end, end,
case transaction(Host, NodeId, Action, sync_dirty) of case transaction(Host, NodeId, Action, sync_dirty) of
{result, {_, Result}} -> {result, Result}; {result, {_, Result}} -> {result, Result};
@ -1209,16 +1209,17 @@ iq_disco_info(Host, NodeId, From, _Lang) ->
node_disco_info(Host, NodeId, From). node_disco_info(Host, NodeId, From).
-spec(iq_disco_items/3 :: -spec(iq_disco_items/4 ::
( (
Host :: hostPubsub(), Host :: hostPubsub(),
NodeId :: nodeId(), NodeId :: nodeId(),
From :: jidEntity()) From :: jidEntity(),
Rsm :: _)
-> {'result', [] | [#xmlel{}]} -> {'result', [] | [#xmlel{}]}
| {'error', _} | {'error', _}
). ).
iq_disco_items(Host, <<>> = _NodeId, Fromi, _Rsm) -> iq_disco_items(Host, <<>> = _NodeId, From, _Rsm) ->
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
Nodes when is_list(Nodes) -> Nodes when is_list(Nodes) ->
{result, lists:map( {result, lists:map(
@ -1438,7 +1439,7 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access,
end; end;
(_, Acc) -> Acc (_, Acc) -> Acc
end, [], exmpp_xml:remove_cdata_from_list(SubEls)), end, [], exmpp_xml:remove_cdata_from_list(SubEls)),
get_items(Host, NodeId, From, SubId, MaxItems, ItemIds, jlib:rsm_decode(SubEl)); get_items(Host, NodeId, From, SubId, MaxItems, ItemIds, jlib:rsm_decode(SubEls));
{'get', 'subscriptions'} -> {'get', 'subscriptions'} ->
get_subscriptions(Host, NodeId, From, Plugins); get_subscriptions(Host, NodeId, From, Plugins);
{'get', 'affiliations'} -> {'get', 'affiliations'} ->
@ -4182,7 +4183,7 @@ tree_call(Host, Function, Args) ->
tree_action(Host, Function, Args) -> tree_action(Host, Function, Args) ->
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]), ?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
Fun = fun() -> tree_call(Host, Function, Args) end), Fun = fun() -> tree_call(Host, Function, Args) end,
case catch ejabberd_odbc:sql_bloc(odbc_conn(Host), Fun) of case catch ejabberd_odbc:sql_bloc(odbc_conn(Host), Fun) of
{atomic, Result} -> {atomic, Result} ->
Result; Result;

View File

@ -1,5 +1,5 @@
--- mod_pubsub.erl 2010-12-07 14:02:57.000000000 +0100 --- mod_pubsub.erl 2010-12-07 19:19:44.000000000 +0100
+++ mod_pubsub_odbc.erl 2010-12-07 15:21:22.000000000 +0100 +++ mod_pubsub_odbc.erl 2010-12-07 19:30:26.000000000 +0100
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see %%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
%%% XEP-0060 section 12.18. %%% XEP-0060 section 12.18.
@ -376,13 +376,14 @@
{result, []} -> ["collection"]; {result, []} -> ["collection"];
{result, _} -> ["leaf", "collection"]; {result, _} -> ["leaf", "collection"];
_ -> [] _ -> []
@@ -1354,9 +1146,14 @@ @@ -1354,10 +1146,15 @@
[#xmlel{ns = ?NS_DISCO_INFO, [#xmlel{ns = ?NS_DISCO_INFO,
name = 'feature', name = 'feature',
attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_b)]} | attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_b)]} |
- [#xmlel{ns = ?NS_DISCO_INFO, - [#xmlel{ns = ?NS_DISCO_INFO,
- name = 'feature', - name = 'feature',
- attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++Type))]} - attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++Type))]}
- || Type <- features(Plugin)]]}
+ lists:map(fun + lists:map(fun
+ ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, + ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO,
+ name = 'feature', + name = 'feature',
@ -390,10 +391,11 @@
+ (T) -> #xmlel{ns = ?NS_DISCO_INFO, + (T) -> #xmlel{ns = ?NS_DISCO_INFO,
+ name = 'feature', + name = 'feature',
+ attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++T))]} + attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++T))]}
+ end, features(Plugin)]} + end, features(Plugin))]}
|| Type <- features(Plugin)]]} + %%|| Type <- features(Plugin)]]}
end, end,
case transaction(Host, NodeId, Action, sync_dirty) of case transaction(Host, NodeId, Action, sync_dirty) of
{result, {_, Result}} -> {result, Result};
@@ -1401,10 +1198,10 @@ @@ -1401,10 +1198,10 @@
name = 'feature', name = 'feature',
attrs = [?XMLATTR(<<"var">>, ?NS_VCARD_b)]}] attrs = [?XMLATTR(<<"var">>, ?NS_VCARD_b)]}]
@ -409,16 +411,28 @@
iq_disco_info(Host, NodeId, From, _Lang) iq_disco_info(Host, NodeId, From, _Lang)
when NodeId == ?NS_ADHOC_b orelse NodeId == ?NS_PUBSUB_GET_PENDING_b -> when NodeId == ?NS_ADHOC_b orelse NodeId == ?NS_PUBSUB_GET_PENDING_b ->
command_disco_info(Host, NodeId, From); command_disco_info(Host, NodeId, From);
@@ -1421,7 +1218,7 @@ @@ -1412,16 +1209,17 @@
node_disco_info(Host, NodeId, From).
--spec(iq_disco_items/3 ::
+-spec(iq_disco_items/4 ::
(
Host :: hostPubsub(),
NodeId :: nodeId(),
- From :: jidEntity())
+ From :: jidEntity(),
+ Rsm :: _)
-> {'result', [] | [#xmlel{}]}
| {'error', _} | {'error', _}
). ).
-iq_disco_items(Host, <<>> = _NodeId, From) -> -iq_disco_items(Host, <<>> = _NodeId, From) ->
+iq_disco_items(Host, <<>> = _NodeId, Fromi, _Rsm) -> +iq_disco_items(Host, <<>> = _NodeId, From, _Rsm) ->
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
Nodes when is_list(Nodes) -> Nodes when is_list(Nodes) ->
{result, lists:map( {result, lists:map(
@@ -1438,7 +1235,7 @@ @@ -1438,7 +1236,7 @@
Other -> Other ->
Other Other
end; end;
@ -427,7 +441,7 @@
%% TODO: support localization of this string %% TODO: support localization of this string
{result, {result,
[#xmlel{ns = ?NS_DISCO_ITEMS, [#xmlel{ns = ?NS_DISCO_ITEMS,
@@ -1446,14 +1243,15 @@ @@ -1446,14 +1244,15 @@
attrs = [?XMLATTR(<<"jid">>, Host), attrs = [?XMLATTR(<<"jid">>, Host),
?XMLATTR(<<"node">>, ?NS_PUBSUB_GET_PENDING_b), ?XMLATTR(<<"node">>, ?NS_PUBSUB_GET_PENDING_b),
?XMLATTR(<<"name">>, "Get Pending")]}]}; ?XMLATTR(<<"name">>, "Get Pending")]}]};
@ -448,7 +462,7 @@
end, end,
Nodes = lists:map( Nodes = lists:map(
fun(#pubsub_node{id = {_, SubNodeId}, options = SubOptions}) -> fun(#pubsub_node{id = {_, SubNodeId}, options = SubOptions}) ->
@@ -1476,7 +1274,7 @@ @@ -1476,7 +1275,7 @@
attrs = [?XMLATTR(<<"jid">>, Host), attrs = [?XMLATTR(<<"jid">>, Host),
?XMLATTR(<<"name">>, Name)]} ?XMLATTR(<<"name">>, Name)]}
end, NodeItems), end, NodeItems),
@ -457,7 +471,7 @@
end, end,
case transaction(Host, NodeId, Action, sync_dirty) of case transaction(Host, NodeId, Action, sync_dirty) of
{result, {_, Result}} -> {result, Result}; {result, {_, Result}} -> {result, Result};
@@ -1485,12 +1283,6 @@ @@ -1485,12 +1284,6 @@
@ -470,16 +484,16 @@
get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups) -> get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups) ->
if (AccessModel == presence) or (AccessModel == roster) -> if (AccessModel == presence) or (AccessModel == roster) ->
case Host of case Host of
@@ -1646,7 +1438,7 @@ @@ -1646,7 +1439,7 @@
end; end;
(_, Acc) -> Acc (_, Acc) -> Acc
end, [], exmpp_xml:remove_cdata_from_list(SubEls)), end, [], exmpp_xml:remove_cdata_from_list(SubEls)),
- get_items(Host, NodeId, From, SubId, MaxItems, ItemIds); - get_items(Host, NodeId, From, SubId, MaxItems, ItemIds);
+ get_items(Host, NodeId, From, SubId, MaxItems, ItemIds, jlib:rsm_decode(SubEl)); + get_items(Host, NodeId, From, SubId, MaxItems, ItemIds, jlib:rsm_decode(SubEls));
{'get', 'subscriptions'} -> {'get', 'subscriptions'} ->
get_subscriptions(Host, NodeId, From, Plugins); get_subscriptions(Host, NodeId, From, Plugins);
{'get', 'affiliations'} -> {'get', 'affiliations'} ->
@@ -1837,7 +1629,8 @@ @@ -1837,7 +1630,8 @@
_ -> [] _ -> []
end end
end, end,
@ -489,7 +503,7 @@
sync_dirty) of sync_dirty) of
{result, Res} -> Res; {result, Res} -> Res;
Err -> Err Err -> Err
@@ -1881,7 +1674,7 @@ @@ -1881,7 +1675,7 @@
%%% authorization handling %%% authorization handling
@ -498,7 +512,7 @@
Lang = <<"en">>, %% TODO fix Lang = <<"en">>, %% TODO fix
{U, S, R} = Subscriber, {U, S, R} = Subscriber,
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children = Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
@@ -1911,7 +1704,7 @@ @@ -1911,7 +1705,7 @@
lists:foreach(fun(Owner) -> lists:foreach(fun(Owner) ->
{U, S, R} = Owner, {U, S, R} = Owner,
ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza) ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza)
@ -507,7 +521,7 @@
find_authorization_response(Packet) -> find_authorization_response(Packet) ->
Els = Packet#xmlel.children, Els = Packet#xmlel.children,
@@ -1970,8 +1763,8 @@ @@ -1970,8 +1764,8 @@
"true" -> true; "true" -> true;
_ -> false _ -> false
end, end,
@ -518,7 +532,7 @@
{result, Subscriptions} = node_call(Type, get_subscriptions, [Nidx, Subscriber]), {result, Subscriptions} = node_call(Type, get_subscriptions, [Nidx, Subscriber]),
if if
not IsApprover -> not IsApprover ->
@@ -2170,7 +1963,7 @@ @@ -2170,7 +1964,7 @@
end, end,
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]}, [#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
@ -527,7 +541,7 @@
{result, {NodeId, SubsByDepth, {Result, broadcast}}} -> {result, {NodeId, SubsByDepth, {Result, broadcast}}} ->
broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth), broadcast_created_node(Host, Node, NodeId, Type, NodeOptions, SubsByDepth),
case Result of case Result of
@@ -2274,7 +2067,7 @@ @@ -2274,7 +2068,7 @@
%%<li>The node does not exist.</li> %%<li>The node does not exist.</li>
%%</ul> %%</ul>
subscribe_node(Host, Node, From, JID, Configuration) -> subscribe_node(Host, Node, From, JID, Configuration) ->
@ -536,7 +550,7 @@
{result, GoodSubOpts} -> GoodSubOpts; {result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid _ -> invalid
end, end,
@@ -2284,7 +2077,7 @@ @@ -2284,7 +2078,7 @@
_:_ -> _:_ ->
{undefined, undefined, undefined} {undefined, undefined, undefined}
end, end,
@ -545,7 +559,7 @@
Features = features(Type), Features = features(Type),
SubscribeFeature = lists:member("subscribe", Features), SubscribeFeature = lists:member("subscribe", Features),
OptionsFeature = lists:member("subscription-options", Features), OptionsFeature = lists:member("subscription-options", Features),
@@ -2293,6 +2086,7 @@ @@ -2293,6 +2087,7 @@
AccessModel = get_option(Options, access_model), AccessModel = get_option(Options, access_model),
SendLast = get_option(Options, send_last_published_item), SendLast = get_option(Options, send_last_published_item),
AllowedGroups = get_option(Options, roster_groups_allowed, []), AllowedGroups = get_option(Options, roster_groups_allowed, []),
@ -553,7 +567,7 @@
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups), {PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups),
if if
not SubscribeFeature -> not SubscribeFeature ->
@@ -2639,7 +2433,7 @@ @@ -2639,7 +2434,7 @@
%% <p>The permission are not checked in this function.</p> %% <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 %% @todo We probably need to check that the user doing the query has the right
%% to read the items. %% to read the items.
@ -562,7 +576,7 @@
MaxItems = MaxItems =
if if
SMaxItems == "" -> get_max_items_node(Host); SMaxItems == "" -> get_max_items_node(Host);
@@ -2653,12 +2447,13 @@ @@ -2653,12 +2448,13 @@
{error, Error} -> {error, Error} ->
{error, Error}; {error, Error};
_ -> _ ->
@ -577,7 +591,7 @@
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups), {PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
if if
not RetreiveFeature -> not RetreiveFeature ->
@@ -2671,11 +2466,11 @@ @@ -2671,11 +2467,11 @@
node_call(Type, get_items, node_call(Type, get_items,
[Nidx, From, [Nidx, From,
AccessModel, PresenceSubscription, RosterGroup, AccessModel, PresenceSubscription, RosterGroup,
@ -591,7 +605,7 @@
SendItems = case ItemIds of SendItems = case ItemIds of
[] -> [] ->
Items; Items;
@@ -2688,7 +2483,7 @@ @@ -2688,7 +2484,7 @@
%% number of items sent to MaxItems: %% number of items sent to MaxItems:
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = {result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children = [#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
@ -600,7 +614,7 @@
Error -> Error ->
Error Error
end end
@@ -2729,6 +2524,17 @@ @@ -2729,6 +2525,17 @@
{result, {_, Items}} -> Items; {result, {_, Items}} -> Items;
Error -> Error Error -> Error
end. end.
@ -618,7 +632,7 @@
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any() %% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
%% Host = pubsubHost() %% Host = pubsubHost()
@@ -2740,16 +2546,29 @@ @@ -2740,16 +2547,29 @@
%% @doc <p>Resend the items of a node to the user.</p> %% @doc <p>Resend the items of a node to the user.</p>
%% @todo use cache-last-item feature %% @todo use cache-last-item feature
send_items(Host, Node, NodeId, Type, LJID, 'last') -> send_items(Host, Node, NodeId, Type, LJID, 'last') ->
@ -654,7 +668,7 @@
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) -> send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
{result, []} -> {result, []} ->
@@ -2876,7 +2695,8 @@ @@ -2876,7 +2696,8 @@
error -> error ->
{error, 'bad-request'}; {error, 'bad-request'};
_ -> _ ->
@ -664,7 +678,7 @@
case lists:member(Owner, Owners) of case lists:member(Owner, Owners) of
true -> true ->
OwnerJID = exmpp_jid:make(Owner), OwnerJID = exmpp_jid:make(Owner),
@@ -2886,24 +2706,8 @@ @@ -2886,24 +2707,8 @@
end, end,
lists:foreach( lists:foreach(
fun({JID, Affiliation}) -> fun({JID, Affiliation}) ->
@ -691,7 +705,7 @@
end, FilteredEntities), end, FilteredEntities),
{result, []}; {result, []};
_ -> _ ->
@@ -2958,11 +2762,11 @@ @@ -2958,11 +2763,11 @@
end. end.
read_sub(Subscriber, Node, NodeId, SubId, Lang) -> read_sub(Subscriber, Node, NodeId, SubId, Lang) ->
@ -705,7 +719,7 @@
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options', OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
attrs = [ ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Subscriber)), attrs = [ ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Subscriber)),
?XMLATTR(<<"subid">>, SubId) | nodeAttr(Node)], ?XMLATTR(<<"subid">>, SubId) | nodeAttr(Node)],
@@ -2989,7 +2793,7 @@ @@ -2989,7 +2794,7 @@
end. end.
set_options_helper(Configuration, JID, NodeId, SubId, Type) -> set_options_helper(Configuration, JID, NodeId, SubId, Type) ->
@ -714,7 +728,7 @@
{result, GoodSubOpts} -> GoodSubOpts; {result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid _ -> invalid
end, end,
@@ -3019,7 +2823,7 @@ @@ -3019,7 +2824,7 @@
write_sub(_Subscriber, _NodeId, _SubId, invalid) -> write_sub(_Subscriber, _NodeId, _SubId, invalid) ->
{error, extended_error('bad-request', "invalid-options")}; {error, extended_error('bad-request', "invalid-options")};
write_sub(Subscriber, NodeId, SubId, Options) -> write_sub(Subscriber, NodeId, SubId, Options) ->
@ -723,7 +737,7 @@
{error, notfound} -> {error, notfound} ->
{error, extended_error('not-acceptable', "invalid-subid")}; {error, extended_error('not-acceptable', "invalid-subid")};
{result, _} -> {result, _} ->
@@ -3193,8 +2997,8 @@ @@ -3193,8 +2998,8 @@
?XMLATTR(<<"subsription">>, subscription_to_string(Sub)) | nodeAttr(Node)]}]}]}, ?XMLATTR(<<"subsription">>, subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
ejabberd_router:route(service_jid(Host), JID, Stanza) ejabberd_router:route(service_jid(Host), JID, Stanza)
end, end,
@ -734,7 +748,7 @@
true -> true ->
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) -> Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
@@ -3557,7 +3361,7 @@ @@ -3557,7 +3362,7 @@
{Depth, [{Node, get_node_subs(Node)} || Node <- Nodes]} {Depth, [{Node, get_node_subs(Node)} || Node <- Nodes]}
end, tree_call(Host, get_parentnodes_tree, [Host, NodeId, service_jid(Host)]))} end, tree_call(Host, get_parentnodes_tree, [Host, NodeId, service_jid(Host)]))}
end, end,
@ -743,7 +757,7 @@
{result, CollSubs} -> CollSubs; {result, CollSubs} -> CollSubs;
_ -> [] _ -> []
end. end.
@@ -3587,7 +3391,7 @@ @@ -3587,7 +3392,7 @@
get_options_for_subs(NodeIdx, Subs) -> get_options_for_subs(NodeIdx, Subs) ->
lists:foldl(fun({Entity, 'subscribed', SubId}, Acc) -> lists:foldl(fun({Entity, 'subscribed', SubId}, Acc) ->
@ -752,7 +766,7 @@
{error, 'notfound'} -> [{Entity, SubId, []} | Acc]; {error, 'notfound'} -> [{Entity, SubId, []} | Acc];
#pubsub_subscription{options = Options} -> [{Entity, SubId, Options} | Acc] #pubsub_subscription{options = Options} -> [{Entity, SubId, Options} | Acc]
end; end;
@@ -3831,6 +3635,30 @@ @@ -3831,6 +3636,30 @@
Result Result
end. end.
@ -783,14 +797,14 @@
%% @spec (Host, Options) -> MaxItems %% @spec (Host, Options) -> MaxItems
%% Host = host() %% Host = host()
%% Options = [Option] %% Options = [Option]
@@ -4354,9 +4182,14 @@ @@ -4354,9 +4183,14 @@
tree_action(Host, Function, Args) -> tree_action(Host, Function, Args) ->
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]), ?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
- %Fun = fun() -> tree_call(Host, Function, Args) end, - %Fun = fun() -> tree_call(Host, Function, Args) end,
- catch mnesia:sync_dirty( - catch mnesia:sync_dirty(
- fun() -> tree_call(Host, Function, Args) end). - fun() -> tree_call(Host, Function, Args) end).
+ Fun = fun() -> tree_call(Host, Function, Args) end), + Fun = fun() -> tree_call(Host, Function, Args) end,
+ case catch ejabberd_odbc:sql_bloc(odbc_conn(Host), Fun) of + case catch ejabberd_odbc:sql_bloc(odbc_conn(Host), Fun) of
+ {atomic, Result} -> + {atomic, Result} ->
+ Result; + Result;
@ -801,7 +815,7 @@
%% @doc <p>node plugin call.</p> %% @doc <p>node plugin call.</p>
-spec(node_call/3 :: -spec(node_call/3 ::
@@ -4394,7 +4227,7 @@ @@ -4394,7 +4228,7 @@
node_action(Host, Type, Function, Args) -> node_action(Host, Type, Function, Args) ->
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]), ?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
@ -810,7 +824,7 @@
node_call(Type, Function, Args) node_call(Type, Function, Args)
end, sync_dirty). end, sync_dirty).
@@ -4409,7 +4242,7 @@ @@ -4409,7 +4243,7 @@
). ).
transaction(Host, NodeId, Action, Trans) -> transaction(Host, NodeId, Action, Trans) ->
@ -819,7 +833,7 @@
case tree_call(Host, get_node, [Host, NodeId]) of case tree_call(Host, get_node, [Host, NodeId]) of
#pubsub_node{} = Node -> #pubsub_node{} = Node ->
case Action(Node) of case Action(Node) of
@@ -4423,7 +4256,7 @@ @@ -4423,7 +4257,7 @@
end, Trans). end, Trans).
@ -828,7 +842,7 @@
( (
Host :: string() | host(), Host :: string() | host(),
Action :: fun(), Action :: fun(),
@@ -4431,21 +4264,28 @@ @@ -4431,21 +4265,28 @@
-> {'result', Nodes :: [] | [Node::pubsubNode()]} -> {'result', Nodes :: [] | [Node::pubsubNode()]}
). ).
@ -862,7 +876,7 @@
{result, Result} -> {result, Result}; {result, Result} -> {result, Result};
{error, Error} -> {error, Error}; {error, Error} -> {error, Error};
{atomic, {result, Result}} -> {result, Result}; {atomic, {result, Result}} -> {result, Result};
@@ -4453,6 +4293,15 @@ @@ -4453,6 +4294,15 @@
{aborted, Reason} -> {aborted, Reason} ->
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]), ?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
{error, 'internal-server-error'}; {error, 'internal-server-error'};
@ -878,7 +892,7 @@
{'EXIT', Reason} -> {'EXIT', Reason} ->
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]), ?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
{error, 'internal-server-error'}; {error, 'internal-server-error'};
@@ -4461,6 +4310,16 @@ @@ -4461,6 +4311,16 @@
{error, 'internal-server-error'} {error, 'internal-server-error'}
end. end.