mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Send authorization messages outside of get-pending transaction (thanks to Brian Cully)(EJAB-1090)
SVN Revision: 2721
This commit is contained in:
parent
64bc97d471
commit
3930715712
@ -1234,17 +1234,12 @@ send_pending_auth_events(Host, Node, Owner) ->
|
||||
?DEBUG("Sending pending auth events for ~s on ~s:~s",
|
||||
[jlib:jid_to_string(Owner), Host, node_to_string(Node)]),
|
||||
Action =
|
||||
fun (#pubsub_node{id = NodeID, type = Type} = N) ->
|
||||
fun (#pubsub_node{id = NodeID, type = Type}) ->
|
||||
case lists:member("get-pending", features(Type)) of
|
||||
true ->
|
||||
case node_call(Type, get_affiliation, [NodeID, Owner]) of
|
||||
{result, owner} ->
|
||||
{result, Subscriptions} = node_call(Type, get_node_subscriptions, [NodeID]),
|
||||
lists:foreach(fun({J, pending, _SubID}) -> send_authorization_request(N, jlib:make_jid(J));
|
||||
({J, pending}) -> send_authorization_request(N, jlib:make_jid(J));
|
||||
(_) -> ok
|
||||
end, Subscriptions),
|
||||
{result, ok};
|
||||
node_call(Type, get_node_subscriptions, [NodeID]);
|
||||
_ ->
|
||||
{error, ?ERR_FORBIDDEN}
|
||||
end;
|
||||
@ -1253,7 +1248,11 @@ send_pending_auth_events(Host, Node, Owner) ->
|
||||
end
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, _} ->
|
||||
{result, {N, Subscriptions}} ->
|
||||
lists:foreach(fun({J, pending, _SubID}) -> send_authorization_request(N, jlib:make_jid(J));
|
||||
({J, pending}) -> send_authorization_request(N, jlib:make_jid(J));
|
||||
(_) -> ok
|
||||
end, Subscriptions),
|
||||
#adhoc_response{};
|
||||
Err ->
|
||||
Err
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2009-10-27 14:53:27.000000000 +0100
|
||||
+++ mod_pubsub_odbc.erl 2009-10-27 14:58:23.000000000 +0100
|
||||
--- mod_pubsub.erl 2009-11-04 20:38:09.000000000 +0100
|
||||
+++ mod_pubsub_odbc.erl 2009-11-04 20:39:02.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.
|
||||
@ -410,7 +410,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1451,7 +1261,7 @@
|
||||
@@ -1450,7 +1260,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -419,7 +419,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
Stanza = {xmlelement, "message",
|
||||
[],
|
||||
@@ -1480,7 +1290,7 @@
|
||||
@@ -1479,7 +1289,7 @@
|
||||
[{xmlelement, "value", [], [{xmlcdata, "false"}]}]}]}]},
|
||||
lists:foreach(fun(Owner) ->
|
||||
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(Owner), Stanza}
|
||||
@ -428,7 +428,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
{xmlelement, _Name, _Attrs, Els} = Packet,
|
||||
@@ -1544,8 +1354,8 @@
|
||||
@@ -1543,8 +1353,8 @@
|
||||
"true" -> true;
|
||||
_ -> false
|
||||
end,
|
||||
@ -439,7 +439,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1736,7 +1546,7 @@
|
||||
@@ -1735,7 +1545,7 @@
|
||||
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "create", nodeAttr(Node),
|
||||
[]}]}],
|
||||
@ -448,7 +448,7 @@
|
||||
{result, {Result, broadcast}} ->
|
||||
%%Lang = "en", %% TODO: fix
|
||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@@ -1844,7 +1654,7 @@
|
||||
@@ -1843,7 +1653,7 @@
|
||||
%%<li>The node does not exist.</li>
|
||||
%%</ul>
|
||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
@ -457,7 +457,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -1852,7 +1662,7 @@
|
||||
@@ -1851,7 +1661,7 @@
|
||||
error -> {"", "", ""};
|
||||
J -> jlib:jid_tolower(J)
|
||||
end,
|
||||
@ -466,7 +466,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1871,9 +1681,13 @@
|
||||
@@ -1870,9 +1680,13 @@
|
||||
{"", "", ""} ->
|
||||
{false, false};
|
||||
_ ->
|
||||
@ -483,7 +483,7 @@
|
||||
end
|
||||
end,
|
||||
if
|
||||
@@ -2204,7 +2018,7 @@
|
||||
@@ -2203,7 +2017,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.
|
||||
@ -492,7 +492,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2243,11 +2057,11 @@
|
||||
@@ -2242,11 +2056,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -506,7 +506,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2260,7 +2074,8 @@
|
||||
@@ -2259,7 +2073,8 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||
[{xmlelement, "items", nodeAttr(Node),
|
||||
@ -516,7 +516,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2292,16 +2107,27 @@
|
||||
@@ -2291,16 +2106,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) ->
|
||||
@ -550,7 +550,7 @@
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2427,29 +2253,12 @@
|
||||
@@ -2426,29 +2252,12 @@
|
||||
error ->
|
||||
{error, ?ERR_BAD_REQUEST};
|
||||
_ ->
|
||||
@ -583,7 +583,7 @@
|
||||
end, Entities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2502,11 +2311,11 @@
|
||||
@@ -2501,11 +2310,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -597,7 +597,7 @@
|
||||
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
||||
{"subid", SubID}|nodeAttr(Node)],
|
||||
[XdataEl]},
|
||||
@@ -2532,7 +2341,7 @@
|
||||
@@ -2531,7 +2340,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -606,7 +606,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2561,7 +2370,7 @@
|
||||
@@ -2560,7 +2369,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -615,7 +615,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2729,8 +2538,8 @@
|
||||
@@ -2728,8 +2537,8 @@
|
||||
{"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
|
||||
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(JID), Stanza}
|
||||
end,
|
||||
@ -626,7 +626,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3014,7 +2823,7 @@
|
||||
@@ -3013,7 +2822,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -635,7 +635,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3028,9 +2837,9 @@
|
||||
@@ -3027,9 +2836,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -647,7 +647,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3228,6 +3037,30 @@
|
||||
@@ -3227,6 +3036,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -678,7 +678,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3614,7 +3447,13 @@
|
||||
@@ -3613,7 +3446,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -693,7 +693,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3634,13 +3473,13 @@
|
||||
@@ -3633,13 +3472,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -709,7 +709,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3653,8 +3492,14 @@
|
||||
@@ -3652,8 +3491,14 @@
|
||||
end
|
||||
end, Trans).
|
||||
|
||||
@ -726,7 +726,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3662,6 +3507,15 @@
|
||||
@@ -3661,6 +3506,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@ -742,7 +742,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@@ -3670,6 +3524,17 @@
|
||||
@@ -3669,6 +3523,17 @@
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user