285
285
% resource not concerned about that subscription
287
@@ -747,10 +550,10 @@
288
disco_identity(_Host, <<>>, _From) ->
289
[{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []}];
290
disco_identity(Host, Node, From) ->
291
- Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
292
+ Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
293
+ Owners = node_owners_call(Type, Idx),
294
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
296
{result, [{xmlelement, "identity", [{"category", "pubsub"}, {"type", "pep"}], []},
299
| [?NS_PUBSUB++"#"++Feature || Feature <- features("pep")]];
300
disco_features(Host, Node, From) ->
301
- Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
302
+ Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
303
+ Owners = node_owners_call(Type, Idx),
304
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
310
disco_items(Host, <<>>, From) ->
311
- Action = fun(#pubsub_node{nodeid ={_, NodeID}, options = Options, type = Type, id = Idx, owners = Owners}, Acc) ->
312
+ Action = fun(#pubsub_node{nodeid ={_, NodeID}, options = Options, type = Type, id = Idx}, Acc) ->
313
+ Owners = node_owners_call(Type, Idx),
314
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
316
[{xmlelement, "item",
317
@@ -695,13 +501,14 @@
321
- case transaction(Host, Action, sync_dirty) of
322
+ case transaction_on_nodes(Host, Action, sync_dirty) of
323
{result, Items} -> Items;
327
disco_items(Host, Node, From) ->
328
- Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
329
+ Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
330
+ Owners = node_owners_call(Type, Idx),
331
case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
333
{result, [{xmlelement, "item",
334
@@ -781,10 +588,10 @@
288
335
lists:foreach(fun(PType) ->
289
336
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
290
337
lists:foreach(fun
367
414
case string:tokens(Item, "!") of
368
415
[_SNode, _ItemID] ->
370
@@ -1122,10 +928,10 @@
371
418
Node = string_to_node(SNode),
373
fun(#pubsub_node{type = Type, id = NodeId}) ->
374
- % TODO call get_items/6 instead for access control (EJAB-1033)
375
- NodeItems = case node_call(Type, get_items, [NodeId, From]) of
376
+ %% TODO call get_items/6 instead for access control (EJAB-1033)
377
+ {NodeItems, RsmOut} = case node_call(Type, get_items, [NodeId, From, RSM]) of
419
- Action = fun(#pubsub_node{id = Idx, type = Type, options = Options, owners = Owners}) ->
420
- NodeItems = case get_allowed_items_call(Host, Idx, From, Type, Options, Owners) of
421
+ Action = fun(#pubsub_node{id = Idx, type = Type, options = Options}) ->
422
+ Owners = node_owners_call(Type, Idx),
423
+ {NodeItems, RsmOut} = case get_allowed_items_call(Host, Idx, From, Type, Options, Owners, RSM) of
382
428
Nodes = lists:map(
383
fun(#pubsub_node{nodeid = {_, SubNode}, options = Options}) ->
429
fun(#pubsub_node{nodeid = {_, SubNode}, options = SubOptions}) ->
385
431
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
386
432
{xmlelement, "item", [{"jid", Host}, {"name", Name}], []}
468
514
{result, GoodSubOpts} -> GoodSubOpts;
471
@@ -1868,7 +1678,7 @@
517
@@ -1880,7 +1695,7 @@
472
518
error -> {"", "", ""};
473
519
J -> jlib:jid_tolower(J)
475
- Action = fun(#pubsub_node{options = Options, owners = [Owner|_], type = Type, id = NodeId}) ->
521
- Action = fun(#pubsub_node{options = Options, owners = Owners, type = Type, id = NodeId}) ->
476
522
+ Action = fun(#pubsub_node{options = Options, type = Type, id = NodeId}) ->
477
523
Features = features(Type),
478
524
SubscribeFeature = lists:member("subscribe", Features),
479
525
OptionsFeature = lists:member("subscription-options", Features),
480
@@ -1887,9 +1697,13 @@
484
- {OU, OS, _} = Owner,
485
- get_roster_info(OU, OS,
486
- Subscriber, AllowedGroups)
487
+ case node_owners_call(Type, NodeId) of
489
+ get_roster_info(OU, OS,
490
+ Subscriber, AllowedGroups);
526
@@ -1889,6 +1704,7 @@
527
AccessModel = get_option(Options, access_model),
528
SendLast = get_option(Options, send_last_published_item),
529
AllowedGroups = get_option(Options, roster_groups_allowed, []),
530
+ Owners = node_owners_call(Type, NodeId),
531
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, Subscriber, Owners, AccessModel, AllowedGroups),
497
@@ -2220,7 +2034,7 @@
533
not SubscribeFeature ->
534
@@ -2218,7 +2034,7 @@
498
535
%% <p>The permission are not checked in this function.</p>
499
536
%% @todo We probably need to check that the user doing the query has the right
500
537
%% to read the items.
505
542
SMaxItems == "" -> get_max_items_node(Host);
506
@@ -2259,11 +2073,11 @@
543
@@ -2232,12 +2048,13 @@
547
- Action = fun(#pubsub_node{options = Options, type = Type, id = NodeId, owners = Owners}) ->
548
+ Action = fun(#pubsub_node{options = Options, type = Type, id = NodeId}) ->
549
Features = features(Type),
550
RetreiveFeature = lists:member("retrieve-items", Features),
551
PersistentFeature = lists:member("persistent-items", Features),
552
AccessModel = get_option(Options, access_model),
553
AllowedGroups = get_option(Options, roster_groups_allowed, []),
554
+ Owners = node_owners_call(Type, NodeId),
555
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
557
not RetreiveFeature ->
558
@@ -2250,11 +2067,11 @@
507
559
node_call(Type, get_items,
509
561
AccessModel, PresenceSubscription, RosterGroup,
530
@@ -2308,16 +2123,27 @@
582
@@ -2289,10 +2107,15 @@
585
get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
586
+ case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners, none) of
587
+ {result, {I, _}} -> {result, I};
590
+get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners, RSM) ->
591
AccessModel = get_option(Options, access_model),
592
AllowedGroups = get_option(Options, roster_groups_allowed, []),
593
{PresenceSubscription, RosterGroup} = get_presence_and_roster_permissions(Host, From, Owners, AccessModel, AllowedGroups),
594
- node_call(Type, get_items, [NodeIdx, From, AccessModel, PresenceSubscription, RosterGroup, undefined]).
595
+ node_call(Type, get_items, [NodeIdx, From, AccessModel, PresenceSubscription, RosterGroup, undefined, RSM]).
598
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
599
@@ -2305,16 +2128,27 @@
531
600
%% @doc <p>Resend the items of a node to the user.</p>
532
601
%% @todo use cache-last-item feature
533
602
send_items(Host, Node, NodeId, Type, LJID, last) ->
723
792
case tree_call(Host, get_node, [Host, Node]) of
724
793
N when is_record(N, pubsub_node) ->
725
794
case Action(N) of
726
@@ -3743,8 +3583,14 @@
795
@@ -3757,13 +3605,19 @@
799
-transaction(Host, Action, Trans) ->
800
- transaction(fun() ->
801
+transaction_on_nodes(Host, Action, Trans) ->
802
+ transaction(Host, fun() ->
803
{result, lists:foldl(Action, [], tree_call(Host, get_nodes, [Host]))}
730
806
-transaction(Fun, Trans) ->
731
807
- case catch mnesia:Trans(Fun) of