]> granicus.if.org Git - ejabberd/commitdiff
Send authorization messages outside of get-pending transaction (thanks to Brian Cully...
authorBadlop <badlop@process-one.net>
Wed, 4 Nov 2009 19:52:33 +0000 (19:52 +0000)
committerBadlop <badlop@process-one.net>
Wed, 4 Nov 2009 19:52:33 +0000 (19:52 +0000)
SVN Revision: 2721

src/mod_pubsub/mod_pubsub_odbc.erl
src/mod_pubsub/pubsub_odbc.patch

index 9ab12c015f5f1420dd2c217f34b9c48c03a74895..1cd449c1640613fa6e645154a16c7246f900cd8b 100644 (file)
@@ -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
index d12c0589d3107d239b8b91e79eb0ea85c418ff26..ac9cdedcf2629ab9bf7e5cd979626a267e1397ba 100644 (file)
@@ -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.
                     sync_dirty) of
        {result, Res} -> Res;
        Err        -> Err
-@@ -1451,7 +1261,7 @@
+@@ -1450,7 +1260,7 @@
  
  %%% authorization handling
  
      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}
  
  find_authorization_response(Packet) ->
      {xmlelement, _Name, _Attrs, Els} = Packet,
-@@ -1544,8 +1354,8 @@
+@@ -1543,8 +1353,8 @@
                        "true" -> true;
                        _ -> false
                    end,
                             {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),
                        []}]}],
                {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) ->
        {result, GoodSubOpts} -> GoodSubOpts;
        _ -> invalid
      end,
-@@ -1852,7 +1662,7 @@
+@@ -1851,7 +1661,7 @@
                     error -> {"", "", ""};
                     J -> jlib:jid_tolower(J)
                 end,
                    Features = features(Type),
                    SubscribeFeature = lists:member("subscribe", Features),
                    OptionsFeature = lists:member("subscription-options", Features),
-@@ -1871,9 +1681,13 @@
+@@ -1870,9 +1680,13 @@
                                    {"", "", ""} ->
                                        {false, false};
                                    _ ->
                                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.
      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,
                    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),
                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) ->
  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};
        _ ->
                                    end, Entities),
                                {result, []};
                            _ ->
-@@ -2502,11 +2311,11 @@
+@@ -2501,11 +2310,11 @@
      end.
  
  read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
            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) ->
        {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) ->
        {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,
                                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,
        {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) ->
                            _ -> Acc
                        end;
                    (_, Acc) ->
-@@ -3228,6 +3037,30 @@
+@@ -3227,6 +3036,30 @@
            Result
      end.
  
  %% @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,
  
  %% @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]),
                        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).
  
        {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};
        {'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.