mirror of
https://github.com/processone/ejabberd.git
synced 2024-10-31 15:21:38 +01:00
Merge branch '3.0.x' of git+ssh://git@gitorious.process-one.net/+ejabberd-developers/ejabberd/maincustomers.git into 3.0.x
This commit is contained in:
commit
a15e689386
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
--- mod_pubsub.erl 2012-08-14 17:49:41.509238095 +0200
|
--- mod_pubsub.erl 2012-10-01 10:05:28.172445600 +0200
|
||||||
+++ mod_pubsub_odbc.erl 2012-08-14 17:52:17.599227806 +0200
|
+++ mod_pubsub_odbc.erl 2012-10-01 11:47:29.225239163 +0200
|
||||||
@@ -41,7 +41,7 @@
|
@@ -41,7 +41,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.
|
||||||
@ -530,28 +530,32 @@
|
|||||||
true ->
|
true ->
|
||||||
% resource not concerned about that subscription
|
% resource not concerned about that subscription
|
||||||
ok
|
ok
|
||||||
@@ -1006,7 +589,8 @@
|
@@ -1032,8 +615,11 @@
|
||||||
children = []}];
|
children = []}];
|
||||||
disco_identity(Host, Node, From) ->
|
disco_identity(Host, Node, From) ->
|
||||||
Action = fun (#pubsub_node{id = Idx, type = Type,
|
Action = fun (#pubsub_node{id = Idx, type = Type,
|
||||||
- options = Options, owners = Owners}) ->
|
- options = Options, owners = Owners}) ->
|
||||||
|
- case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
|
||||||
+ options = Options}) ->
|
+ options = Options}) ->
|
||||||
+ Owners = node_owners_call(Type, Idx),
|
+ Owners = node_owners_call(Type, Idx),
|
||||||
case get_allowed_items_call(Host, Idx, From, Type,
|
+ case get_allowed_items_call(Host, Idx, From, Type,
|
||||||
Options, Owners)
|
+ Options, Owners)
|
||||||
of
|
+ of
|
||||||
@@ -1054,7 +638,8 @@
|
{result, _} ->
|
||||||
|
{result,
|
||||||
|
[#xmlel{name = <<"identity">>,
|
||||||
|
@@ -1084,7 +670,8 @@
|
||||||
|| Feature <- features(<<"pep">>)]];
|
|| Feature <- features(<<"pep">>)]];
|
||||||
disco_features(Host, Node, From) ->
|
disco_features(Host, Node, From) ->
|
||||||
Action = fun (#pubsub_node{id = Idx, type = Type,
|
Action = fun (#pubsub_node{id = Idx, type = Type,
|
||||||
- options = Options, owners = Owners}) ->
|
- options = Options, owners = Owners}) ->
|
||||||
+ options = Options}) ->
|
+ options = Options}) ->
|
||||||
+ Owners = node_owners_call(Type, Idx),
|
+ Owners = node_owners_call(Type, Idx),
|
||||||
case get_allowed_items_call(Host, Idx, From, Type,
|
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
|
||||||
Options, Owners)
|
{result, _} ->
|
||||||
of
|
{result,
|
||||||
@@ -1087,9 +672,9 @@
|
@@ -1129,9 +716,9 @@
|
||||||
|
).
|
||||||
disco_items(Host, <<>>, From) ->
|
disco_items(Host, <<>>, From) ->
|
||||||
Action = fun (#pubsub_node{nodeid = {_, NodeID},
|
Action = fun (#pubsub_node{nodeid = {_, NodeID},
|
||||||
- options = Options, type = Type, id = Idx,
|
- options = Options, type = Type, id = Idx,
|
||||||
@ -559,10 +563,10 @@
|
|||||||
+ options = Options, type = Type, id = Idx},
|
+ options = Options, type = Type, id = Idx},
|
||||||
Acc) ->
|
Acc) ->
|
||||||
+ Owners = node_owners_call(Type, Idx),
|
+ Owners = node_owners_call(Type, Idx),
|
||||||
case get_allowed_items_call(Host, Idx, From, Type,
|
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
|
||||||
Options, Owners)
|
{result, _} ->
|
||||||
of
|
[#xmlel{name = <<"item">>,
|
||||||
@@ -1112,13 +697,14 @@
|
@@ -1152,13 +739,14 @@
|
||||||
_ -> Acc
|
_ -> Acc
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -579,7 +583,7 @@
|
|||||||
case get_allowed_items_call(Host, Idx, From, Type,
|
case get_allowed_items_call(Host, Idx, From, Type,
|
||||||
Options, Owners)
|
Options, Owners)
|
||||||
of
|
of
|
||||||
@@ -1231,9 +817,6 @@
|
@@ -1262,9 +850,6 @@
|
||||||
lists:foreach(fun ({#pubsub_node{options
|
lists:foreach(fun ({#pubsub_node{options
|
||||||
=
|
=
|
||||||
Options,
|
Options,
|
||||||
@ -589,7 +593,7 @@
|
|||||||
id =
|
id =
|
||||||
NodeId},
|
NodeId},
|
||||||
subscribed, _,
|
subscribed, _,
|
||||||
@@ -1245,7 +828,9 @@
|
@@ -1276,7 +861,9 @@
|
||||||
presence ->
|
presence ->
|
||||||
case
|
case
|
||||||
lists:member(BJID,
|
lists:member(BJID,
|
||||||
@ -600,7 +604,7 @@
|
|||||||
of
|
of
|
||||||
true ->
|
true ->
|
||||||
node_action(Host,
|
node_action(Host,
|
||||||
@@ -1316,7 +901,7 @@
|
@@ -1347,7 +934,7 @@
|
||||||
{H,
|
{H,
|
||||||
N},
|
N},
|
||||||
type =
|
type =
|
||||||
@ -609,7 +613,7 @@
|
|||||||
owner})
|
owner})
|
||||||
when N ==
|
when N ==
|
||||||
HomeTreeBase ->
|
HomeTreeBase ->
|
||||||
@@ -1465,7 +1050,8 @@
|
@@ -1495,7 +1082,8 @@
|
||||||
IQ ->
|
IQ ->
|
||||||
#xmlel{attrs = QAttrs} = SubEl,
|
#xmlel{attrs = QAttrs} = SubEl,
|
||||||
Node = xml:get_attr_s(<<"node">>, QAttrs),
|
Node = xml:get_attr_s(<<"node">>, QAttrs),
|
||||||
@ -619,7 +623,7 @@
|
|||||||
{result, IQRes} ->
|
{result, IQRes} ->
|
||||||
jlib:iq_to_xml(IQ#iq{type = result,
|
jlib:iq_to_xml(IQ#iq{type = result,
|
||||||
sub_el =
|
sub_el =
|
||||||
@@ -1588,7 +1174,8 @@
|
@@ -1669,7 +1257,8 @@
|
||||||
[] -> [<<"leaf">>];
|
[] -> [<<"leaf">>];
|
||||||
_ ->
|
_ ->
|
||||||
case node_call(Type, get_items,
|
case node_call(Type, get_items,
|
||||||
@ -629,7 +633,7 @@
|
|||||||
of
|
of
|
||||||
{result, []} ->
|
{result, []} ->
|
||||||
[<<"collection">>];
|
[<<"collection">>];
|
||||||
@@ -1610,7 +1197,13 @@
|
@@ -1691,7 +1280,13 @@
|
||||||
F = [#xmlel{name = <<"feature">>,
|
F = [#xmlel{name = <<"feature">>,
|
||||||
attrs = [{<<"var">>, ?NS_PUBSUB}],
|
attrs = [{<<"var">>, ?NS_PUBSUB}],
|
||||||
children = []}
|
children = []}
|
||||||
@ -644,7 +648,7 @@
|
|||||||
#xmlel{name = <<"feature">>,
|
#xmlel{name = <<"feature">>,
|
||||||
attrs =
|
attrs =
|
||||||
[{<<"var">>,
|
[{<<"var">>,
|
||||||
@@ -1654,12 +1247,16 @@
|
@@ -1735,10 +1330,16 @@
|
||||||
#xmlel{name = <<"feature">>,
|
#xmlel{name = <<"feature">>,
|
||||||
attrs = [{<<"var">>, ?NS_VCARD}], children = []}]
|
attrs = [{<<"var">>, ?NS_VCARD}], children = []}]
|
||||||
++
|
++
|
||||||
@ -656,38 +660,47 @@
|
|||||||
+ (T) ->
|
+ (T) ->
|
||||||
#xmlel{name = <<"feature">>,
|
#xmlel{name = <<"feature">>,
|
||||||
attrs =
|
attrs =
|
||||||
[{<<"var">>,
|
- [{<<"var">>, <<(?NS_PUBSUB)/binary, "#", Feature/binary>>}],
|
||||||
<<(?NS_PUBSUB)/binary, "#",
|
+ [{<<"var">>,
|
||||||
- Feature/binary>>}],
|
+ <<(?NS_PUBSUB)/binary, "#",
|
||||||
+ T/binary>>}],
|
+ T/binary>>}],
|
||||||
children = []}
|
children = []}
|
||||||
end,
|
end,
|
||||||
features(Host, Node))};
|
features(Host, Node))};
|
||||||
@@ -1669,7 +1266,7 @@
|
@@ -1748,14 +1349,15 @@
|
||||||
_ -> node_disco_info(Host, Node, From)
|
_ -> node_disco_info(Host, Node, From)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
--spec(iq_disco_items/3 ::
|
||||||
|
+-spec(iq_disco_items/4 ::
|
||||||
|
(
|
||||||
|
Host :: mod_pubsub:host(),
|
||||||
|
NodeId :: <<>> | mod_pubsub:nodeId(),
|
||||||
|
- From :: jid())
|
||||||
|
+ From :: jid(),
|
||||||
|
+ Rsm :: none | rsm_in())
|
||||||
|
-> {result, [xmlel()]}
|
||||||
|
).
|
||||||
-iq_disco_items(Host, <<>>, From) ->
|
-iq_disco_items(Host, <<>>, From) ->
|
||||||
+iq_disco_items(Host, [], From, _RSM) ->
|
+iq_disco_items(Host, <<>>, From, _RSM) ->
|
||||||
case tree_action(Host, get_subnodes, [Host, <<>>, From])
|
{result,
|
||||||
of
|
lists:map(fun (#pubsub_node{nodeid = {_, SubNode},
|
||||||
Nodes when is_list(Nodes) ->
|
options = Options}) ->
|
||||||
@@ -1691,7 +1288,7 @@
|
@@ -1792,7 +1394,7 @@
|
||||||
Nodes)};
|
% Nodes)};
|
||||||
Other -> Other
|
% Other -> Other
|
||||||
end;
|
% end;
|
||||||
-iq_disco_items(Host, ?NS_COMMANDS, _From) ->
|
-iq_disco_items(Host, ?NS_COMMANDS, _From) ->
|
||||||
+iq_disco_items(Host, ?NS_COMMANDS, _From, _RSM) ->
|
+iq_disco_items(Host, ?NS_COMMANDS, _From, _RSM) ->
|
||||||
CommandItems = [#xmlel{name = <<"item">>,
|
CommandItems = [#xmlel{name = <<"item">>,
|
||||||
attrs =
|
attrs =
|
||||||
[{<<"jid">>, Host},
|
[{<<"jid">>, Host},
|
||||||
@@ -1699,23 +1296,29 @@
|
@@ -1800,23 +1402,28 @@
|
||||||
{<<"name">>, <<"Get Pending">>}],
|
{<<"name">>, <<"Get Pending">>}],
|
||||||
children = []}],
|
children = []}],
|
||||||
{result, CommandItems};
|
{result, CommandItems};
|
||||||
-iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From) ->
|
-iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From) ->
|
||||||
+iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From,
|
+iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From, _RSM) ->
|
||||||
+ _RSM) ->
|
|
||||||
CommandItems = [], {result, CommandItems};
|
CommandItems = [], {result, CommandItems};
|
||||||
-iq_disco_items(Host, Item, From) ->
|
-iq_disco_items(Host, Item, From) ->
|
||||||
+iq_disco_items(Host, Item, From, RSM) ->
|
+iq_disco_items(Host, Item, From, RSM) ->
|
||||||
@ -722,7 +735,7 @@
|
|||||||
Nodes = lists:map(fun (#pubsub_node{nodeid =
|
Nodes = lists:map(fun (#pubsub_node{nodeid =
|
||||||
{_, SubNode},
|
{_, SubNode},
|
||||||
options =
|
options =
|
||||||
@@ -1757,7 +1360,7 @@
|
@@ -1858,7 +1465,7 @@
|
||||||
children = []}
|
children = []}
|
||||||
end,
|
end,
|
||||||
NodeItems),
|
NodeItems),
|
||||||
@ -731,55 +744,39 @@
|
|||||||
end,
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {_, Result}} -> {result, Result};
|
{result, {_, Result}} -> {result, Result};
|
||||||
@@ -1906,7 +1509,9 @@
|
@@ -2009,7 +1616,8 @@
|
||||||
(_, Acc) -> Acc
|
(_, Acc) -> Acc
|
||||||
end,
|
end,
|
||||||
[], xml:remove_cdata(Els)),
|
[], xml:remove_cdata(Els)),
|
||||||
- get_items(Host, Node, From, SubId, MaxItems, ItemIDs);
|
- get_items(Host, Node, From, SubId, MaxItems, ItemIDs);
|
||||||
+ RSM = jlib:rsm_decode(SubEl),
|
+ RSM = jlib:rsm_decode(SubEl),
|
||||||
+ get_items(Host, Node, From, SubId, MaxItems, ItemIDs,
|
+ get_items(Host, Node, From, SubId, MaxItems, ItemIDs, RSM);
|
||||||
+ RSM);
|
|
||||||
{get, <<"subscriptions">>} ->
|
{get, <<"subscriptions">>} ->
|
||||||
get_subscriptions(Host, Node, From, Plugins);
|
get_subscriptions(Host, Node, From, Plugins);
|
||||||
{get, <<"affiliations">>} ->
|
{get, <<"affiliations">>} ->
|
||||||
@@ -1929,7 +1534,11 @@
|
@@ -2174,7 +1782,7 @@
|
||||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl,
|
|
||||||
Lang) ->
|
|
||||||
#xmlel{children = SubEls} = SubEl,
|
|
||||||
- Action = xml:remove_cdata(SubEls),
|
|
||||||
+ Action = lists:filter(fun (#xmlel{name = <<"set">>}) ->
|
|
||||||
+ false;
|
|
||||||
+ (_) -> true
|
|
||||||
+ end,
|
|
||||||
+ xml:remove_cdata(SubEls)),
|
|
||||||
case Action of
|
|
||||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
|
||||||
Node = xml:get_attr_s(<<"node">>, Attrs),
|
|
||||||
@@ -2061,9 +1670,8 @@
|
|
||||||
_ -> []
|
_ -> []
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
- case transaction(fun () ->
|
- case transaction(fun () ->
|
||||||
- {result, lists:flatmap(Tr, Plugins)}
|
+ case transaction(Host, fun () ->
|
||||||
- end,
|
{result, lists:flatmap(Tr, Plugins)}
|
||||||
+ case transaction(Host,
|
end,
|
||||||
+ fun () -> {result, lists:flatmap(Tr, Plugins)} end,
|
|
||||||
sync_dirty)
|
sync_dirty)
|
||||||
of
|
@@ -2216,8 +1824,10 @@
|
||||||
{result, Res} -> Res;
|
|
||||||
@@ -2103,8 +1711,9 @@
|
|
||||||
|
|
||||||
%%% authorization handling
|
%%% authorization handling
|
||||||
|
|
||||||
-send_authorization_request(#pubsub_node{owners = Owners,
|
-send_authorization_request(#pubsub_node{owners = Owners, nodeid = {Host, Node}},
|
||||||
- nodeid = {Host, Node}},
|
- Subscriber) ->
|
||||||
+send_authorization_request(#pubsub_node{nodeid =
|
+send_authorization_request(#pubsub_node{nodeid =
|
||||||
+ {Host, Node},
|
+ {Host, Node},
|
||||||
+ type = Type, id = NodeId},
|
+ type = Type, id = NodeId},
|
||||||
Subscriber) ->
|
+ Subscriber) ->
|
||||||
Lang = <<"en">>,
|
Lang = <<"en">>,
|
||||||
Stanza = #xmlel{name = <<"message">>, attrs = [],
|
Stanza = #xmlel{name = <<"message">>, attrs = [],
|
||||||
@@ -2182,7 +1791,7 @@
|
children =
|
||||||
|
@@ -2294,7 +1904,7 @@
|
||||||
ejabberd_router:route(service_jid(Host),
|
ejabberd_router:route(service_jid(Host),
|
||||||
jlib:make_jid(Owner), Stanza)
|
jlib:make_jid(Owner), Stanza)
|
||||||
end,
|
end,
|
||||||
@ -788,7 +785,7 @@
|
|||||||
|
|
||||||
find_authorization_response(Packet) ->
|
find_authorization_response(Packet) ->
|
||||||
#xmlel{children = Els} = Packet,
|
#xmlel{children = Els} = Packet,
|
||||||
@@ -2242,11 +1851,10 @@
|
@@ -2353,11 +1963,10 @@
|
||||||
<<"true">> -> true;
|
<<"true">> -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end,
|
end,
|
||||||
@ -802,7 +799,7 @@
|
|||||||
{result, Subscriptions} = node_call(Type,
|
{result, Subscriptions} = node_call(Type,
|
||||||
get_subscriptions,
|
get_subscriptions,
|
||||||
[NodeId,
|
[NodeId,
|
||||||
@@ -2470,7 +2078,7 @@
|
@@ -2597,7 +2206,7 @@
|
||||||
children =
|
children =
|
||||||
[#xmlel{name = <<"create">>,
|
[#xmlel{name = <<"create">>,
|
||||||
attrs = nodeAttr(Node), children = []}]}],
|
attrs = nodeAttr(Node), children = []}]}],
|
||||||
@ -811,8 +808,8 @@
|
|||||||
{result, {NodeId, {Result, broadcast}}} ->
|
{result, {NodeId, {Result, broadcast}}} ->
|
||||||
broadcast_created_node(Host, Node, NodeId, Type,
|
broadcast_created_node(Host, Node, NodeId, Type,
|
||||||
NodeOptions),
|
NodeOptions),
|
||||||
@@ -2563,7 +2171,7 @@
|
@@ -2709,7 +2318,7 @@
|
||||||
|
).
|
||||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||||
SubOpts = case
|
SubOpts = case
|
||||||
- pubsub_subscription:parse_options_xform(Configuration)
|
- pubsub_subscription:parse_options_xform(Configuration)
|
||||||
@ -820,53 +817,64 @@
|
|||||||
of
|
of
|
||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
@@ -2573,7 +2181,7 @@
|
@@ -2723,7 +2332,7 @@
|
||||||
J -> jlib:jid_tolower(J)
|
end
|
||||||
end,
|
end,
|
||||||
Action = fun (#pubsub_node{options = Options,
|
Action = fun (#pubsub_node{options = Options,
|
||||||
- owners = Owners, type = Type, id = NodeId}) ->
|
- owners = Owners, type = Type, id = NodeId}) ->
|
||||||
+ type = Type, id = NodeId}) ->
|
+ type = Type, id = NodeId}) ->
|
||||||
Features = features(Type),
|
Features = features(Type),
|
||||||
SubscribeFeature = lists:member(<<"subscribe">>,
|
SubscribeFeature = lists:member(<<"subscribe">>, Features),
|
||||||
Features),
|
OptionsFeature = lists:member(<<"subscription-options">>, Features),
|
||||||
@@ -2586,6 +2194,7 @@
|
@@ -2732,6 +2341,7 @@
|
||||||
send_last_published_item),
|
AccessModel = get_option(Options, access_model),
|
||||||
AllowedGroups = get_option(Options,
|
SendLast = get_option(Options, send_last_published_item),
|
||||||
roster_groups_allowed, []),
|
AllowedGroups = get_option(Options, roster_groups_allowed, []),
|
||||||
+ Owners = node_owners_call(Type, NodeId),
|
+ Owners = node_owners_call(Type, NodeId),
|
||||||
{PresenceSubscription, RosterGroup} =
|
{PresenceSubscription, RosterGroup} =
|
||||||
get_presence_and_roster_permissions(Host, Subscriber,
|
get_presence_and_roster_permissions(Host, Subscriber,
|
||||||
Owners,
|
Owners, AccessModel, AllowedGroups),
|
||||||
@@ -2899,8 +2508,8 @@
|
@@ -3076,19 +2686,20 @@
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-get_items(Host, Node, From, SubId, SMaxItems,
|
--spec(get_items/6 ::
|
||||||
- ItemIDs) ->
|
+-spec(get_items/7 ::
|
||||||
+get_items(Host, Node, From, SubId, SMaxItems, ItemIDs,
|
(
|
||||||
+ RSM) ->
|
Host :: mod_pubsub:host(),
|
||||||
|
Node :: mod_pubsub:nodeId(),
|
||||||
|
From :: jid(),
|
||||||
|
SubId :: mod_pubsub:subId(),
|
||||||
|
SMaxItems :: binary(),
|
||||||
|
- ItemIDs :: [mod_pubsub:itemId()])
|
||||||
|
+ ItemIDs :: [mod_pubsub:itemId()],
|
||||||
|
+ Rsm :: none | rsm_in())
|
||||||
|
-> {result, [xmlel(),...]}
|
||||||
|
%%%
|
||||||
|
| {error, xmlel()}
|
||||||
|
).
|
||||||
|
-get_items(Host, Node, From, SubId, SMaxItems, ItemIDs) ->
|
||||||
|
+get_items(Host, Node, From, SubId, SMaxItems, ItemIDs, RSM) ->
|
||||||
MaxItems = if SMaxItems == <<"">> ->
|
MaxItems = if SMaxItems == <<"">> ->
|
||||||
get_max_items_node(Host);
|
get_max_items_node(Host);
|
||||||
true ->
|
true ->
|
||||||
@@ -2913,8 +2522,7 @@
|
@@ -3100,13 +2711,13 @@
|
||||||
|
case MaxItems of
|
||||||
{error, Error} -> {error, Error};
|
{error, Error} -> {error, Error};
|
||||||
_ ->
|
_ ->
|
||||||
Action = fun (#pubsub_node{options = Options,
|
- Action = fun (#pubsub_node{options = Options, type = Type, id = NodeId,
|
||||||
- type = Type, id = NodeId,
|
|
||||||
- owners = Owners}) ->
|
- owners = Owners}) ->
|
||||||
+ type = Type, id = NodeId}) ->
|
+ Action = fun (#pubsub_node{options = Options, type = Type, id = NodeId}) ->
|
||||||
Features = features(Type),
|
Features = features(Type),
|
||||||
RetreiveFeature = lists:member(<<"retrieve-items">>,
|
RetreiveFeature = lists:member(<<"retrieve-items">>, Features),
|
||||||
Features),
|
PersistentFeature = lists:member(<<"persistent-items">>, Features),
|
||||||
@@ -2924,6 +2532,7 @@
|
AccessModel = get_option(Options, access_model),
|
||||||
AllowedGroups = get_option(Options,
|
AllowedGroups = get_option(Options, roster_groups_allowed, []),
|
||||||
roster_groups_allowed,
|
|
||||||
[]),
|
|
||||||
+ Owners = node_owners_call(Type, NodeId),
|
+ Owners = node_owners_call(Type, NodeId),
|
||||||
{PresenceSubscription, RosterGroup} =
|
{PresenceSubscription, RosterGroup} =
|
||||||
get_presence_and_roster_permissions(Host, From,
|
get_presence_and_roster_permissions(Host, From, Owners,
|
||||||
Owners,
|
AccessModel, AllowedGroups),
|
||||||
@@ -2943,11 +2552,11 @@
|
@@ -3124,11 +2735,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From, AccessModel,
|
[NodeId, From, AccessModel,
|
||||||
PresenceSubscription, RosterGroup,
|
PresenceSubscription, RosterGroup,
|
||||||
@ -880,7 +888,7 @@
|
|||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] -> Items;
|
[] -> Items;
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2966,7 +2575,8 @@
|
@@ -3147,7 +2758,8 @@
|
||||||
[#xmlel{name = <<"items">>, attrs = nodeAttr(Node),
|
[#xmlel{name = <<"items">>, attrs = nodeAttr(Node),
|
||||||
children =
|
children =
|
||||||
itemsEls(lists:sublist(SendItems,
|
itemsEls(lists:sublist(SendItems,
|
||||||
@ -890,10 +898,13 @@
|
|||||||
Error -> Error
|
Error -> Error
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
@@ -2991,6 +2601,15 @@
|
@@ -3170,42 +2782,68 @@
|
||||||
|
Error -> Error
|
||||||
|
end.
|
||||||
|
|
||||||
get_allowed_items_call(Host, NodeIdx, From, Type,
|
-get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
|
||||||
Options, Owners) ->
|
+get_allowed_items_call(Host, NodeIdx, From, Type,
|
||||||
|
+ Options, Owners) ->
|
||||||
+ case get_allowed_items_call(Host, NodeIdx, From, Type,
|
+ case get_allowed_items_call(Host, NodeIdx, From, Type,
|
||||||
+ Options, Owners, none)
|
+ Options, Owners, none)
|
||||||
+ of
|
+ of
|
||||||
@ -904,17 +915,20 @@
|
|||||||
+get_allowed_items_call(Host, NodeIdx, From, Type,
|
+get_allowed_items_call(Host, NodeIdx, From, Type,
|
||||||
+ Options, Owners, RSM) ->
|
+ Options, Owners, RSM) ->
|
||||||
AccessModel = get_option(Options, access_model),
|
AccessModel = get_option(Options, access_model),
|
||||||
AllowedGroups = get_option(Options,
|
- AllowedGroups = get_option(Options, roster_groups_allowed, []),
|
||||||
roster_groups_allowed, []),
|
+ AllowedGroups = get_option(Options,
|
||||||
@@ -2999,36 +2618,49 @@
|
+ roster_groups_allowed, []),
|
||||||
AccessModel, AllowedGroups),
|
{PresenceSubscription, RosterGroup} =
|
||||||
|
- get_presence_and_roster_permissions(Host, From, Owners, AccessModel,
|
||||||
|
- AllowedGroups),
|
||||||
|
+ get_presence_and_roster_permissions(Host, From, Owners,
|
||||||
|
+ AccessModel, AllowedGroups),
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeIdx, From, AccessModel, PresenceSubscription,
|
- [NodeIdx, From, AccessModel, PresenceSubscription, RosterGroup, undefined]).
|
||||||
- RosterGroup, undefined]).
|
+ [NodeIdx, From, AccessModel, PresenceSubscription,
|
||||||
+ RosterGroup, undefined, RSM]).
|
+ RosterGroup, undefined, RSM]).
|
||||||
|
|
||||||
send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
|
-send_items(Host, Node, NodeId, Type, {U, S, R} = LJID, last) ->
|
||||||
last) ->
|
|
||||||
- case get_cached_item(Host, NodeId) of
|
- case get_cached_item(Host, NodeId) of
|
||||||
- undefined ->
|
- undefined ->
|
||||||
- send_items(Host, Node, NodeId, Type, LJID, 1);
|
- send_items(Host, Node, NodeId, Type, LJID, 1);
|
||||||
@ -923,6 +937,8 @@
|
|||||||
- LastItem#pubsub_item.modification,
|
- LastItem#pubsub_item.modification,
|
||||||
- Stanza = event_stanza_with_delay([#xmlel{name =
|
- Stanza = event_stanza_with_delay([#xmlel{name =
|
||||||
- <<"items">>,
|
- <<"items">>,
|
||||||
|
+send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
|
||||||
|
+ last) ->
|
||||||
+ Stanza = case get_cached_item(Host, NodeId) of
|
+ Stanza = case get_cached_item(Host, NodeId) of
|
||||||
+ undefined ->
|
+ undefined ->
|
||||||
+ case node_action(Host, Type, get_last_items,
|
+ case node_action(Host, Type, get_last_items,
|
||||||
@ -980,99 +996,61 @@
|
|||||||
end
|
end
|
||||||
end;
|
end;
|
||||||
send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
|
send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
|
||||||
@@ -3232,9 +2864,8 @@
|
@@ -3436,9 +3074,8 @@
|
||||||
case Entities of
|
case Entities of
|
||||||
error -> {error, ?ERR_BAD_REQUEST};
|
error -> {error, ?ERR_BAD_REQUEST};
|
||||||
_ ->
|
_ ->
|
||||||
- Action = fun (#pubsub_node{owners = Owners, type = Type,
|
- Action = fun (#pubsub_node{owners = Owners, type = Type,
|
||||||
- id = NodeId} =
|
- id = NodeId} =
|
||||||
- N) ->
|
- N) ->
|
||||||
+ Action = fun (#pubsub_node{type = Type, id = NodeId}) ->
|
+ Action = fun (#pubsub_node{type = Type, id = NodeId} = N) ->
|
||||||
+ Owners = node_owners_call(Type, NodeId),
|
+ Owners = node_owners_call(Type, NodeId),
|
||||||
case lists:member(Owner, Owners) of
|
case lists:member(Owner, Owners) of
|
||||||
true ->
|
true ->
|
||||||
OwnerJID = jlib:make_jid(Owner),
|
OwnerJID = jlib:make_jid(Owner),
|
||||||
@@ -3250,39 +2881,7 @@
|
@@ -3545,10 +3182,10 @@
|
||||||
node_call(Type,
|
|
||||||
set_affiliation,
|
|
||||||
[NodeId, JID,
|
|
||||||
- Affiliation]),
|
|
||||||
- case Affiliation of
|
|
||||||
- owner ->
|
|
||||||
- NewOwner =
|
|
||||||
- jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
|
||||||
- NewOwners =
|
|
||||||
- [NewOwner
|
|
||||||
- | Owners],
|
|
||||||
- tree_call(Host,
|
|
||||||
- set_node,
|
|
||||||
- [N#pubsub_node{owners
|
|
||||||
- =
|
|
||||||
- NewOwners}]);
|
|
||||||
- none ->
|
|
||||||
- OldOwner =
|
|
||||||
- jlib:jid_tolower(jlib:jid_remove_resource(JID)),
|
|
||||||
- case
|
|
||||||
- lists:member(OldOwner,
|
|
||||||
- Owners)
|
|
||||||
- of
|
|
||||||
- true ->
|
|
||||||
- NewOwners =
|
|
||||||
- Owners --
|
|
||||||
- [OldOwner],
|
|
||||||
- tree_call(Host,
|
|
||||||
- set_node,
|
|
||||||
- [N#pubsub_node{owners
|
|
||||||
- =
|
|
||||||
- NewOwners}]);
|
|
||||||
- _ -> ok
|
|
||||||
- end;
|
|
||||||
- _ -> ok
|
|
||||||
- end
|
|
||||||
+ Affiliation])
|
|
||||||
end,
|
|
||||||
FilteredEntities),
|
|
||||||
{result, []};
|
|
||||||
@@ -3342,10 +2941,13 @@
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||||
- case pubsub_subscription:get_subscription(Subscriber, NodeID, SubID) of
|
- case pubsub_subscription:get_subscription(Subscriber, NodeID, SubID) of
|
||||||
+ case
|
+ case pubsub_subscription_odbc:get_subscription(Subscriber, NodeID, SubID) of
|
||||||
+ pubsub_subscription_odbc:get_subscription(Subscriber, NodeID, SubID)
|
|
||||||
+ of
|
|
||||||
{result, #pubsub_subscription{options = Options}} ->
|
{result, #pubsub_subscription{options = Options}} ->
|
||||||
{result, XdataEl} =
|
{result, XdataEl} =
|
||||||
- pubsub_subscription:get_options_xform(Lang, Options),
|
- pubsub_subscription:get_options_xform(Lang, Options),
|
||||||
+ pubsub_subscription_odbc:get_options_xform(Lang,
|
+ pubsub_subscription_odbc:get_options_xform(Lang, Options),
|
||||||
+ Options),
|
|
||||||
OptionsEl = #xmlel{name = <<"options">>,
|
OptionsEl = #xmlel{name = <<"options">>,
|
||||||
attrs =
|
attrs =
|
||||||
[{<<"jid">>, jlib:jid_to_string(Subscriber)},
|
[{<<"jid">>, jlib:jid_to_string(Subscriber)},
|
||||||
@@ -3392,7 +2994,7 @@
|
@@ -3593,7 +3230,7 @@
|
||||||
set_options_helper(Configuration, JID, NodeID, SubID,
|
end.
|
||||||
Type) ->
|
|
||||||
SubOpts = case
|
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||||
- pubsub_subscription:parse_options_xform(Configuration)
|
- SubOpts = case pubsub_subscription:parse_options_xform(Configuration) of
|
||||||
+ pubsub_subscription_odbc:parse_options_xform(Configuration)
|
+ SubOpts = case pubsub_subscription_odbc:parse_options_xform(Configuration) of
|
||||||
of
|
|
||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
@@ -3654,9 +3256,10 @@
|
end,
|
||||||
|
@@ -3629,7 +3266,7 @@
|
||||||
|
write_sub(_Subscriber, _NodeID, _SubID, []) ->
|
||||||
|
{result, []};
|
||||||
|
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||||
|
- case pubsub_subscription:set_subscription(Subscriber,
|
||||||
|
+ case pubsub_subscription_odbc:set_subscription(Subscriber,
|
||||||
|
NodeID, SubID, Options)
|
||||||
|
of
|
||||||
|
{result, _} -> {result, []};
|
||||||
|
@@ -3854,8 +3491,8 @@
|
||||||
ejabberd_router:route(service_jid(Host),
|
ejabberd_router:route(service_jid(Host),
|
||||||
jlib:make_jid(JID), Stanza)
|
jlib:make_jid(JID), Stanza)
|
||||||
end,
|
end,
|
||||||
- Action = fun (#pubsub_node{owners = Owners, type = Type,
|
- Action = fun (#pubsub_node{owners = Owners, type = Type,
|
||||||
- id = NodeId}) ->
|
- id = NodeId}) ->
|
||||||
- case lists:member(Owner, Owners) of
|
|
||||||
+ Action = fun (#pubsub_node{type = Type, id = NodeId}) ->
|
+ Action = fun (#pubsub_node{type = Type, id = NodeId}) ->
|
||||||
+ case lists:member(Owner,
|
+ Owners = node_owners_call(Type, NodeId),
|
||||||
+ node_owners_call(Type, NodeId))
|
case lists:member(Owner, Owners) of
|
||||||
+ of
|
|
||||||
true ->
|
true ->
|
||||||
Result = lists:foldl(fun ({JID, Subscription,
|
Result = lists:foldl(fun ({JID, Subscription,
|
||||||
SubId},
|
@@ -4347,7 +3984,7 @@
|
||||||
@@ -4110,7 +3713,7 @@
|
|
||||||
[{Depth, [{N, sub_with_options(N)} || N <- Nodes]}
|
[{Depth, [{N, sub_with_options(N)} || N <- Nodes]}
|
||||||
|| {Depth, Nodes} <- Collection]}
|
|| {Depth, Nodes} <- Collection]}
|
||||||
end,
|
end,
|
||||||
@ -1081,21 +1059,20 @@
|
|||||||
{result, CollSubs} ->
|
{result, CollSubs} ->
|
||||||
subscribed_nodes_by_jid(NotifyType, CollSubs);
|
subscribed_nodes_by_jid(NotifyType, CollSubs);
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -4207,10 +3810,10 @@
|
@@ -4443,10 +4080,10 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
sub_with_options(JID, NodeId, SubId) ->
|
sub_with_options(JID, NodeId, SubId) ->
|
||||||
- case pubsub_subscription:read_subscription(JID, NodeId,
|
- case pubsub_subscription:read_subscription(JID, NodeId,
|
||||||
- SubId)
|
+ case pubsub_subscription_odbc:get_subscription(JID, NodeId,
|
||||||
+ case pubsub_subscription_odbc:get_subscription(JID,
|
SubId)
|
||||||
+ NodeId, SubId)
|
|
||||||
of
|
of
|
||||||
- #pubsub_subscription{options = Options} ->
|
- #pubsub_subscription{options = Options} ->
|
||||||
+ {result, #pubsub_subscription{options = Options}} ->
|
+ {result, #pubsub_subscription{options = Options}} ->
|
||||||
{JID, SubId, Options};
|
{JID, SubId, Options};
|
||||||
_ -> {JID, SubId, []}
|
_ -> {JID, SubId, []}
|
||||||
end.
|
end.
|
||||||
@@ -4301,6 +3904,28 @@
|
@@ -4537,6 +4174,28 @@
|
||||||
Result -> Result
|
Result -> Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -1124,7 +1101,7 @@
|
|||||||
max_items(Host, Options) ->
|
max_items(Host, Options) ->
|
||||||
case get_option(Options, persist_items) of
|
case get_option(Options, persist_items) of
|
||||||
true ->
|
true ->
|
||||||
@@ -4788,7 +4413,14 @@
|
@@ -5024,7 +4683,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,
|
||||||
@ -1140,24 +1117,22 @@
|
|||||||
|
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
?DEBUG("node_call ~p ~p ~p", [Type, Function, Args]),
|
?DEBUG("node_call ~p ~p ~p", [Type, Function, Args]),
|
||||||
@@ -4812,12 +4444,13 @@
|
@@ -5048,12 +4714,12 @@
|
||||||
node_action(Host, Type, Function, Args) ->
|
node_action(Host, Type, Function, Args) ->
|
||||||
?DEBUG("node_action ~p ~p ~p ~p",
|
?DEBUG("node_action ~p ~p ~p ~p",
|
||||||
[Host, Type, Function, Args]),
|
[Host, Type, Function, Args]),
|
||||||
- transaction(fun () -> node_call(Type, Function, Args)
|
- transaction(fun () -> node_call(Type, Function, Args)
|
||||||
- end,
|
+ transaction(Host, fun () -> node_call(Type, Function, Args)
|
||||||
+ transaction(Host,
|
end,
|
||||||
+ fun () -> node_call(Type, Function, Args) end,
|
|
||||||
sync_dirty).
|
sync_dirty).
|
||||||
|
|
||||||
transaction(Host, Node, Action, Trans) ->
|
transaction(Host, Node, Action, Trans) ->
|
||||||
- transaction(fun () ->
|
- transaction(fun () ->
|
||||||
+ transaction(Host,
|
+ transaction(Host, fun () ->
|
||||||
+ fun () ->
|
|
||||||
case tree_call(Host, get_node, [Host, Node]) of
|
case tree_call(Host, get_node, [Host, Node]) of
|
||||||
N when is_record(N, pubsub_node) ->
|
N when is_record(N, pubsub_node) ->
|
||||||
case Action(N) of
|
case Action(N) of
|
||||||
@@ -4831,16 +4464,24 @@
|
@@ -5067,16 +4733,24 @@
|
||||||
end,
|
end,
|
||||||
Trans).
|
Trans).
|
||||||
|
|
||||||
@ -1186,7 +1161,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};
|
||||||
@@ -4849,6 +4490,16 @@
|
@@ -5085,6 +4759,16 @@
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n",
|
?ERROR_MSG("transaction return internal error: ~p~n",
|
||||||
[{aborted, Reason}]),
|
[{aborted, Reason}]),
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
@ -1203,7 +1178,7 @@
|
|||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n",
|
?ERROR_MSG("transaction return internal error: ~p~n",
|
||||||
[{'EXIT', Reason}]),
|
[{'EXIT', Reason}]),
|
||||||
@@ -4859,6 +4510,20 @@
|
@@ -5095,6 +4779,20 @@
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user