From 08b0530164bd0907536f3c0a00467908451cea20 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Wed, 16 Dec 2015 12:56:06 +0100 Subject: [PATCH] Don't read pubsub options when plugin does not use them This also revert commit 6052f7b --- src/mod_pubsub.erl | 11 +++++++++-- src/node_flat.erl | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index c0b613d61..a3494067e 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -3424,12 +3424,19 @@ get_node_subs_by_depth(Host, Node, From) -> [{Depth, [{N, get_node_subs(Host, N)} || N <- Nodes]} || {Depth, Nodes} <- ParentTree]. get_node_subs(Host, #pubsub_node{type = Type, id = Nidx}) -> + WithOptions = lists:member(<<"subscription-options">>, plugin_features(Host, Type)), case node_call(Host, Type, get_node_subscriptions, [Nidx]) of - {result, Subs} -> get_options_for_subs(Host, Nidx, Subs); + {result, Subs} -> get_options_for_subs(Host, Nidx, Subs, WithOptions); Other -> Other end. -get_options_for_subs(Host, Nidx, Subs) -> +get_options_for_subs(_Host, _Nidx, Subs, false) -> + lists:foldl(fun({JID, subscribed, SubID}, Acc) -> + [{JID, SubID, []} | Acc]; + (_, Acc) -> + Acc + end, [], Subs); +get_options_for_subs(Host, Nidx, Subs, true) -> SubModule = subscription_plugin(Host), lists:foldl(fun({JID, subscribed, SubID}, Acc) -> case SubModule:get_subscription(JID, Nidx, SubID) of diff --git a/src/node_flat.erl b/src/node_flat.erl index 8acfd48c5..e35dd6e9b 100644 --- a/src/node_flat.erl +++ b/src/node_flat.erl @@ -50,7 +50,7 @@ path_to_node/1, can_fetch_item/2, is_subscribed/1]). init(_Host, _ServerHost, _Opts) -> - pubsub_subscription:init(), + %pubsub_subscription:init(), mnesia:create_table(pubsub_state, [{disc_copies, [node()]}, {type, ordered_set},