|
1 |
| ---- mod_pubsub.erl 2011-08-31 16:42:23.000000000 +0200 |
2 |
| -+++ mod_pubsub_odbc.erl 2011-08-31 16:42:23.000000000 +0200 |
| 1 | +--- mod_pubsub.erl 2011-09-21 14:40:16.000000000 +0200 |
| 2 | ++++ mod_pubsub_odbc.erl 2011-09-21 14:40:29.000000000 +0200 |
3 | 3 | @@ -42,7 +42,7 @@
|
4 | 4 | %%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
|
5 | 5 | %%% XEP-0060 section 12.18.
|
|
621 | 621 | {PayloadCount, PayloadNS} = payload_els_ns(Payload),
|
622 | 622 | PayloadSize = size(term_to_binary(Payload))-2, % size(term_to_binary([])) == 2
|
623 | 623 | PayloadMaxSize = get_option(Options, max_payload_size),
|
624 |
| -@@ -2642,7 +2434,7 @@ |
| 624 | +@@ -2645,7 +2437,7 @@ |
625 | 625 | %% <p>The permission are not checked in this function.</p>
|
626 | 626 | %% @todo We probably need to check that the user doing the query has the right
|
627 | 627 | %% to read the items.
|
|
630 | 630 | MaxItems =
|
631 | 631 | if
|
632 | 632 | SMaxItems == "" -> get_max_items_node(Host);
|
633 |
| -@@ -2656,12 +2448,13 @@ |
| 633 | +@@ -2659,12 +2451,13 @@ |
634 | 634 | {error, Error} ->
|
635 | 635 | {error, Error};
|
636 | 636 | _ ->
|
|
645 | 645 | {PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
|
646 | 646 | if
|
647 | 647 | not RetreiveFeature ->
|
648 |
| -@@ -2674,11 +2467,11 @@ |
| 648 | +@@ -2677,11 +2470,11 @@ |
649 | 649 | node_call(Type, get_items,
|
650 | 650 | [Nidx, From,
|
651 | 651 | AccessModel, PresenceSubscription, RosterGroup,
|
|
659 | 659 | SendItems = case ItemIds of
|
660 | 660 | [] ->
|
661 | 661 | Items;
|
662 |
| -@@ -2691,7 +2484,7 @@ |
| 662 | +@@ -2694,7 +2487,7 @@ |
663 | 663 | %% number of items sent to MaxItems:
|
664 | 664 | {result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
665 | 665 | [#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
|
668 | 668 | Error ->
|
669 | 669 | Error
|
670 | 670 | end
|
671 |
| -@@ -2707,8 +2500,8 @@ |
| 671 | +@@ -2710,8 +2503,8 @@ |
672 | 672 | ).
|
673 | 673 |
|
674 | 674 | get_items(Host, NodeId) ->
|
|
679 | 679 | end,
|
680 | 680 | case transaction(Host, NodeId, Action, sync_dirty) of
|
681 | 681 | {result, {_, Items}} -> Items
|
682 |
| -@@ -2725,13 +2518,24 @@ |
| 682 | +@@ -2728,13 +2521,24 @@ |
683 | 683 | ).
|
684 | 684 |
|
685 | 685 | get_item(Host, NodeId, ItemId) ->
|
|
706 | 706 |
|
707 | 707 | %% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
|
708 | 708 | %% Host = pubsubHost()
|
709 |
| -@@ -2742,32 +2546,32 @@ |
| 709 | +@@ -2745,32 +2549,32 @@ |
710 | 710 | %% Number = last | integer()
|
711 | 711 | %% @doc <p>Resend the items of a node to the user.</p>
|
712 | 712 | %% @todo use cache-last-item feature
|
|
761 | 761 | {result, []} ->
|
762 | 762 | [];
|
763 | 763 | {result, Items} ->
|
764 |
| -@@ -2789,20 +2593,7 @@ |
| 764 | +@@ -2792,20 +2596,7 @@ |
765 | 765 | [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = nodeAttr(Node), children =
|
766 | 766 | itemsEls(ToSend)}])
|
767 | 767 | end,
|
|
783 | 783 |
|
784 | 784 | %% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
|
785 | 785 | %% Host = host()
|
786 |
| -@@ -2905,7 +2696,8 @@ |
| 786 | +@@ -2908,7 +2699,8 @@ |
787 | 787 | error ->
|
788 | 788 | {error, 'bad-request'};
|
789 | 789 | _ ->
|
|
793 | 793 | case lists:member(Owner, Owners) of
|
794 | 794 | true ->
|
795 | 795 | OwnerJID = exmpp_jid:make(Owner),
|
796 |
| -@@ -2915,24 +2707,8 @@ |
| 796 | +@@ -2918,24 +2710,8 @@ |
797 | 797 | end,
|
798 | 798 | lists:foreach(
|
799 | 799 | fun({JID, Affiliation}) ->
|
|
820 | 820 | end, FilteredEntities),
|
821 | 821 | {result, []};
|
822 | 822 | _ ->
|
823 |
| -@@ -2961,7 +2737,7 @@ |
| 823 | +@@ -2964,7 +2740,7 @@ |
824 | 824 | Error -> Error
|
825 | 825 | end.
|
826 | 826 |
|
|
829 | 829 | Subscriber = try exmpp_jid:parse(JID) of
|
830 | 830 | J -> jlib:short_jid(J)
|
831 | 831 | catch
|
832 |
| -@@ -2969,7 +2745,7 @@ |
| 832 | +@@ -2972,7 +2748,7 @@ |
833 | 833 | exmpp_jid:make("", "", "") %% TODO, check if use <<>> instead of ""
|
834 | 834 | end,
|
835 | 835 | {result, Subs} = node_call(Type, get_subscriptions,
|
|
838 | 838 | SubIds = lists:foldl(fun({subscribed, SID}, Acc) ->
|
839 | 839 | [SID | Acc];
|
840 | 840 | (_, Acc) ->
|
841 |
| -@@ -2979,17 +2755,17 @@ |
| 841 | +@@ -2982,17 +2758,17 @@ |
842 | 842 | {_, []} ->
|
843 | 843 | {error, extended_error('not-acceptable', "not-subscribed")};
|
844 | 844 | {[], [SID]} ->
|
|
861 | 861 | OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
862 | 862 | attrs = [ ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Subscriber)),
|
863 | 863 | ?XMLATTR(<<"subid">>, SubId) | nodeAttr(Node)],
|
864 |
| -@@ -3021,8 +2797,8 @@ |
| 864 | +@@ -3024,8 +2800,8 @@ |
865 | 865 | Error -> Error
|
866 | 866 | end.
|
867 | 867 |
|
|
872 | 872 | {result, GoodSubOpts} -> GoodSubOpts;
|
873 | 873 | _ -> invalid
|
874 | 874 | end,
|
875 |
| -@@ -3032,7 +2808,7 @@ |
| 875 | +@@ -3035,7 +2811,7 @@ |
876 | 876 | _ -> exmpp_jid:make("", "", "") %% TODO, check if use <<>> instead of ""
|
877 | 877 | end,
|
878 | 878 | {result, Subs} = node_call(Type, get_subscriptions,
|
|
881 | 881 | SubIds = lists:foldl(fun({subscribed, SID}, Acc) ->
|
882 | 882 | [SID | Acc];
|
883 | 883 | (_, Acc) ->
|
884 |
| -@@ -3042,19 +2818,19 @@ |
| 884 | +@@ -3045,19 +2821,19 @@ |
885 | 885 | {_, []} ->
|
886 | 886 | {error, extended_error('not-acceptable', "not-subscribed")};
|
887 | 887 | {[], [SID]} ->
|
|
907 | 907 | {result, _} ->
|
908 | 908 | {result, []};
|
909 | 909 | {error, _} ->
|
910 |
| -@@ -3228,8 +3004,8 @@ |
| 910 | +@@ -3231,8 +3007,8 @@ |
911 | 911 | ?XMLATTR(<<"subsription">>, subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
912 | 912 | ejabberd_router:route(service_jid(Host), JID, Stanza)
|
913 | 913 | end,
|
|
918 | 918 | true ->
|
919 | 919 | Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
920 | 920 |
|
921 |
| -@@ -3583,7 +3359,7 @@ |
| 921 | +@@ -3586,7 +3362,7 @@ |
922 | 922 | Collection = tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]),
|
923 | 923 | {result, [{Depth, [{N, sub_with_options(N)} || N <- Nodes]} || {Depth, Nodes} <- Collection]}
|
924 | 924 | end,
|
|
927 | 927 | {result, CollSubs} -> subscribed_nodes_by_jid(NotifyType, CollSubs);
|
928 | 928 | _ -> []
|
929 | 929 | end.
|
930 |
| -@@ -3641,19 +3417,19 @@ |
| 930 | +@@ -3644,19 +3420,19 @@ |
931 | 931 | {_, JIDSubs} = lists:foldl(DepthsToDeliver, {[], []}, SubsByDepth),
|
932 | 932 | JIDSubs.
|
933 | 933 |
|
|
953 | 953 | _ -> {JID, SubId, []}
|
954 | 954 | end.
|
955 | 955 |
|
956 |
| -@@ -3765,6 +3541,30 @@ |
| 956 | +@@ -3768,6 +3544,30 @@ |
957 | 957 | Result
|
958 | 958 | end.
|
959 | 959 |
|
|
984 | 984 | %% @spec (Host, Options) -> MaxItems
|
985 | 985 | %% Host = host()
|
986 | 986 | %% Options = [Option]
|
987 |
| -@@ -4288,9 +4088,14 @@ |
| 987 | +@@ -4291,9 +4091,14 @@ |
988 | 988 |
|
989 | 989 | tree_action(Host, Function, Args) ->
|
990 | 990 | ?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
|
1002 | 1002 |
|
1003 | 1003 | %% @doc <p>node plugin call.</p>
|
1004 | 1004 | -spec(node_call/3 ::
|
1005 |
| -@@ -4328,7 +4133,7 @@ |
| 1005 | +@@ -4331,7 +4136,7 @@ |
1006 | 1006 |
|
1007 | 1007 | node_action(Host, Type, Function, Args) ->
|
1008 | 1008 | ?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
|
1011 | 1011 | node_call(Type, Function, Args)
|
1012 | 1012 | end, sync_dirty).
|
1013 | 1013 |
|
1014 |
| -@@ -4343,7 +4148,7 @@ |
| 1014 | +@@ -4346,7 +4151,7 @@ |
1015 | 1015 | ).
|
1016 | 1016 |
|
1017 | 1017 | transaction(Host, NodeId, Action, Trans) ->
|
|
1020 | 1020 | case tree_call(Host, get_node, [Host, NodeId]) of
|
1021 | 1021 | #pubsub_node{} = Node ->
|
1022 | 1022 | case Action(Node) of
|
1023 |
| -@@ -4357,7 +4162,7 @@ |
| 1023 | +@@ -4360,7 +4165,7 @@ |
1024 | 1024 | end, Trans).
|
1025 | 1025 |
|
1026 | 1026 |
|
|
1029 | 1029 | (
|
1030 | 1030 | Host :: string() | host(),
|
1031 | 1031 | Action :: fun(),
|
1032 |
| -@@ -4365,21 +4170,28 @@ |
| 1032 | +@@ -4368,21 +4173,28 @@ |
1033 | 1033 | -> {'result', Nodes :: [] | [Node::pubsubNode()]}
|
1034 | 1034 | ).
|
1035 | 1035 |
|
|
1063 | 1063 | {result, Result} -> {result, Result};
|
1064 | 1064 | {error, Error} -> {error, Error};
|
1065 | 1065 | {atomic, {result, Result}} -> {result, Result};
|
1066 |
| -@@ -4387,6 +4199,15 @@ |
| 1066 | +@@ -4390,6 +4202,15 @@ |
1067 | 1067 | {aborted, Reason} ->
|
1068 | 1068 | ?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
1069 | 1069 | {error, 'internal-server-error'};
|
|
1079 | 1079 | {'EXIT', Reason} ->
|
1080 | 1080 | ?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
1081 | 1081 | {error, 'internal-server-error'};
|
1082 |
| -@@ -4395,6 +4216,16 @@ |
| 1082 | +@@ -4398,6 +4219,16 @@ |
1083 | 1083 | {error, 'internal-server-error'}
|
1084 | 1084 | end.
|
1085 | 1085 |
|
|
0 commit comments