mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
PubSub: NodeIdx variable name cleanup
This commit is contained in:
parent
970f74288b
commit
dfd7936ea6
@ -594,10 +594,10 @@ send_loop(State) ->
|
|||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun({Node, subscribed, _, SubJID}) ->
|
fun({Node, subscribed, _, SubJID}) ->
|
||||||
if (SubJID == LJID) or (SubJID == BJID) ->
|
if (SubJID == LJID) or (SubJID == BJID) ->
|
||||||
#pubsub_node{id = {H, NodeId}, type = Type, idx = NodeIdx, options = Options} = Node,
|
#pubsub_node{id = {H, NodeId}, type = Type, idx = Nidx, options = Options} = Node,
|
||||||
case get_option(Options, 'send_last_published_item') of
|
case get_option(Options, 'send_last_published_item') of
|
||||||
'on_sub_and_presence' ->
|
'on_sub_and_presence' ->
|
||||||
send_items(H, NodeId, NodeIdx, Type, LJID, 'last');
|
send_items(H, NodeId, Nidx, Type, LJID, 'last');
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end;
|
end;
|
||||||
@ -646,7 +646,7 @@ send_loop(State) ->
|
|||||||
spawn(fun() ->
|
spawn(fun() ->
|
||||||
Host = State#state.host,
|
Host = State#state.host,
|
||||||
Owner = {U,S,undefined},
|
Owner = {U,S,undefined},
|
||||||
lists:foreach(fun(#pubsub_node{id = {_, NodeId}, type = Type, idx = NodeIdx, options = Options}) ->
|
lists:foreach(fun(#pubsub_node{id = {_, NodeId}, type = Type, idx = Nidx, options = Options}) ->
|
||||||
case get_option(Options, 'send_last_published_item') of
|
case get_option(Options, 'send_last_published_item') of
|
||||||
'on_sub_and_presence' ->
|
'on_sub_and_presence' ->
|
||||||
lists:foreach(fun(Resource) ->
|
lists:foreach(fun(Resource) ->
|
||||||
@ -660,7 +660,7 @@ send_loop(State) ->
|
|||||||
RosterGroups = get_option(Options, 'roster_groups_allowed', []),
|
RosterGroups = get_option(Options, 'roster_groups_allowed', []),
|
||||||
element(2, get_roster_info(U, S, LJID, RosterGroups))
|
element(2, get_roster_info(U, S, LJID, RosterGroups))
|
||||||
end,
|
end,
|
||||||
if Subscribed -> send_items(Owner, NodeId, NodeIdx, Type, LJID, 'last');
|
if Subscribed -> send_items(Owner, NodeId, Nidx, Type, LJID, 'last');
|
||||||
true -> ok
|
true -> ok
|
||||||
end
|
end
|
||||||
end, Resources);
|
end, Resources);
|
||||||
@ -763,8 +763,8 @@ disco_identity(_Host, <<>> = _NodeId, _From) ->
|
|||||||
[#xmlel{name = 'identity', ns = ?NS_DISCO_INFO,
|
[#xmlel{name = 'identity', ns = ?NS_DISCO_INFO,
|
||||||
attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]}];
|
attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]}];
|
||||||
disco_identity(#jid{node = U, domain = S, resource = R} = Host, NodeId, From) ->
|
disco_identity(#jid{node = U, domain = S, resource = R} = Host, NodeId, From) ->
|
||||||
Action = fun(#pubsub_node{idx = NodeIdx, type = Type, options = Options, owners = Owners}) ->
|
Action = fun(#pubsub_node{idx = Nidx, type = Type, options = Options, owners = Owners}) ->
|
||||||
case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) of
|
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
{result,
|
{result,
|
||||||
[#xmlel{name = 'identity', ns = ?NS_DISCO_INFO,
|
[#xmlel{name = 'identity', ns = ?NS_DISCO_INFO,
|
||||||
@ -813,8 +813,8 @@ disco_features(_Host, <<>> = _NodeId, _From) ->
|
|||||||
[?NS_PUBSUB_s
|
[?NS_PUBSUB_s
|
||||||
| [?NS_PUBSUB_s++"#"++Feature || Feature <- features("pep")]];
|
| [?NS_PUBSUB_s++"#"++Feature || Feature <- features("pep")]];
|
||||||
disco_features(#jid{node = U, domain = S, resource = R} = Host, NodeId, From) ->
|
disco_features(#jid{node = U, domain = S, resource = R} = Host, NodeId, From) ->
|
||||||
Action = fun(#pubsub_node{idx = NodeIdx, type = Type, options = Options, owners = Owners}) ->
|
Action = fun(#pubsub_node{idx = Nidx, type = Type, options = Options, owners = Owners}) ->
|
||||||
case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) of
|
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
{result, [?NS_PUBSUB_s
|
{result, [?NS_PUBSUB_s
|
||||||
| [?NS_PUBSUB_s ++ "#" ++ Feature || Feature <- features("pep")]]};
|
| [?NS_PUBSUB_s ++ "#" ++ Feature || Feature <- features("pep")]]};
|
||||||
@ -853,8 +853,8 @@ disco_sm_items({result, OtherItems} = _Acc, From, To, NodeId, _Lang) ->
|
|||||||
).
|
).
|
||||||
|
|
||||||
disco_items(#jid{raw = JID, node = U, domain = S, resource = R} = Host, <<>>, From) ->
|
disco_items(#jid{raw = JID, node = U, domain = S, resource = R} = Host, <<>>, From) ->
|
||||||
Action = fun(#pubsub_node{id ={_, NodeId}, options = Options, type = Type, idx = NodeIdx, owners = Owners}, Acc) ->
|
Action = fun(#pubsub_node{id ={_, NodeId}, options = Options, type = Type, idx = Nidx, owners = Owners}, Acc) ->
|
||||||
case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) of
|
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
[#xmlel{name = 'item', ns = ?NS_DISCO_INFO,
|
[#xmlel{name = 'item', ns = ?NS_DISCO_INFO,
|
||||||
attrs = [?XMLATTR(<<"jid">>, JID),
|
attrs = [?XMLATTR(<<"jid">>, JID),
|
||||||
@ -873,8 +873,8 @@ disco_items(#jid{raw = JID, node = U, domain = S, resource = R} = Host, <<>>, Fr
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
disco_items(#jid{raw = JID, node = U, domain = S, resource = R} = Host, NodeId, From) ->
|
disco_items(#jid{raw = JID, node = U, domain = S, resource = R} = Host, NodeId, From) ->
|
||||||
Action = fun(#pubsub_node{idx = NodeIdx, type = Type, options = Options, owners = Owners}) ->
|
Action = fun(#pubsub_node{idx = Nidx, type = Type, options = Options, owners = Owners}) ->
|
||||||
case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) of
|
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
|
||||||
{result, Items} ->
|
{result, Items} ->
|
||||||
{result,
|
{result,
|
||||||
[#xmlel{name = 'item', ns = ?NS_DISCO_INFO,
|
[#xmlel{name = 'item', ns = ?NS_DISCO_INFO,
|
||||||
@ -1331,11 +1331,11 @@ command_disco_info(_Host, ?NS_PUBSUB_GET_PENDING_b = _NodeId, _From) ->
|
|||||||
).
|
).
|
||||||
|
|
||||||
node_disco_info(Host, NodeId, From) ->
|
node_disco_info(Host, NodeId, From) ->
|
||||||
Action = fun(#pubsub_node{type = Plugin, idx = NodeIdx}) ->
|
Action = fun(#pubsub_node{type = Plugin, idx = Nidx}) ->
|
||||||
Types = case tree_call(Host, get_subnodes, [Host, NodeId, From]) of
|
Types = case tree_call(Host, get_subnodes, [Host, NodeId, From]) of
|
||||||
[] -> ["leaf"];
|
[] -> ["leaf"];
|
||||||
_ ->
|
_ ->
|
||||||
case node_call(Plugin, get_items, [NodeIdx, From]) of
|
case node_call(Plugin, get_items, [Nidx, From]) of
|
||||||
{result, []} -> ["collection"];
|
{result, []} -> ["collection"];
|
||||||
{result, _} -> ["leaf", "collection"];
|
{result, _} -> ["leaf", "collection"];
|
||||||
_ -> []
|
_ -> []
|
||||||
@ -1449,8 +1449,8 @@ iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING_b = _NodeId, _From) ->
|
|||||||
%% TODO
|
%% TODO
|
||||||
{result, []};
|
{result, []};
|
||||||
iq_disco_items(Host, NodeId, From) ->
|
iq_disco_items(Host, NodeId, From) ->
|
||||||
Action = fun(#pubsub_node{idx = NodeIdx, type = Type, options = Options, owners = Owners}) ->
|
Action = fun(#pubsub_node{idx = Nidx, type = Type, options = Options, owners = Owners}) ->
|
||||||
NodeItems = case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) of
|
NodeItems = case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
|
||||||
{result, R} -> R;
|
{result, R} -> R;
|
||||||
_ -> []
|
_ -> []
|
||||||
end,
|
end,
|
||||||
@ -2698,8 +2698,8 @@ get_items(Host, Node, From, SubId, SMaxItems, ItemIds) ->
|
|||||||
).
|
).
|
||||||
|
|
||||||
get_items(Host, NodeId) ->
|
get_items(Host, NodeId) ->
|
||||||
Action = fun(#pubsub_node{type = Type, idx = NodeIdx}) ->
|
Action = fun(#pubsub_node{type = Type, idx = Nidx}) ->
|
||||||
node_call(Type, get_items, [NodeIdx, service_jid(Host)])
|
node_call(Type, get_items, [Nidx, service_jid(Host)])
|
||||||
end,
|
end,
|
||||||
case transaction(Host, NodeId, Action, sync_dirty) of
|
case transaction(Host, NodeId, Action, sync_dirty) of
|
||||||
{result, {_, Items}} -> Items
|
{result, {_, Items}} -> Items
|
||||||
@ -2716,8 +2716,8 @@ get_items(Host, NodeId) ->
|
|||||||
).
|
).
|
||||||
|
|
||||||
get_item(Host, NodeId, ItemId) ->
|
get_item(Host, NodeId, ItemId) ->
|
||||||
Action = fun(#pubsub_node{type = Type, idx = NodeIdx}) ->
|
Action = fun(#pubsub_node{type = Type, idx = Nidx}) ->
|
||||||
node_call(Type, get_item, [NodeIdx, ItemId])
|
node_call(Type, get_item, [Nidx, ItemId])
|
||||||
end,
|
end,
|
||||||
case transaction(Host, NodeId, Action, sync_dirty) of
|
case transaction(Host, NodeId, Action, sync_dirty) of
|
||||||
{result, {_, Items}} -> Items;
|
{result, {_, Items}} -> Items;
|
||||||
@ -2733,10 +2733,10 @@ get_item(Host, NodeId, ItemId) ->
|
|||||||
%% Number = last | integer()
|
%% Number = last | integer()
|
||||||
%% @doc <p>Resend the items of a node to the user.</p>
|
%% @doc <p>Resend the items of a node to the user.</p>
|
||||||
%% @todo use cache-last-item feature
|
%% @todo use cache-last-item feature
|
||||||
send_items(Host, Node, NodeId, Type, LJID, 'last') ->
|
send_items(Host, Node, Nidx, Type, LJID, 'last') ->
|
||||||
case get_cached_item(Host, NodeId) of
|
case get_cached_item(Host, Nidx) of
|
||||||
undefined ->
|
undefined ->
|
||||||
send_items(Host, Node, NodeId, Type, LJID, 1);
|
send_items(Host, Node, Nidx, Type, LJID, 1);
|
||||||
LastItem ->
|
LastItem ->
|
||||||
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
{ModifNow, ModifUSR} = LastItem#pubsub_item.modification,
|
||||||
Stanza = event_stanza_with_delay(
|
Stanza = event_stanza_with_delay(
|
||||||
@ -2744,8 +2744,8 @@ send_items(Host, Node, NodeId, Type, LJID, 'last') ->
|
|||||||
children = itemsEls([LastItem])}], ModifNow, ModifUSR),
|
children = itemsEls([LastItem])}], ModifNow, ModifUSR),
|
||||||
ejabberd_router:route(service_jid(Host), exmpp_jid:make(LJID), Stanza)
|
ejabberd_router:route(service_jid(Host), exmpp_jid:make(LJID), Stanza)
|
||||||
end;
|
end;
|
||||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
send_items(Host, Node, Nidx, Type, {LU, LS, LR} = LJID, Number) ->
|
||||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
ToSend = case node_action(Host, Type, get_items, [Nidx, LJID]) of
|
||||||
{result, []} ->
|
{result, []} ->
|
||||||
[];
|
[];
|
||||||
{result, Items} ->
|
{result, Items} ->
|
||||||
@ -2926,7 +2926,7 @@ get_options(Host, Node, JID, SubId, Lang) ->
|
|||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_options_helper(JID, Lang, Node, NodeId, SubId, Type) ->
|
get_options_helper(JID, Lang, Node, Nidx, SubId, Type) ->
|
||||||
Subscriber = try exmpp_jid:parse(JID) of
|
Subscriber = try exmpp_jid:parse(JID) of
|
||||||
J -> jlib:short_jid(J)
|
J -> jlib:short_jid(J)
|
||||||
catch
|
catch
|
||||||
@ -2934,7 +2934,7 @@ get_options_helper(JID, Lang, Node, NodeId, SubId, Type) ->
|
|||||||
exmpp_jid:make("", "", "") %% TODO, check if use <<>> instead of ""
|
exmpp_jid:make("", "", "") %% TODO, check if use <<>> instead of ""
|
||||||
end,
|
end,
|
||||||
{result, Subs} = node_call(Type, get_subscriptions,
|
{result, Subs} = node_call(Type, get_subscriptions,
|
||||||
[NodeId, Subscriber]),
|
[Nidx, Subscriber]),
|
||||||
SubIds = lists:foldl(fun({subscribed, SID}, Acc) ->
|
SubIds = lists:foldl(fun({subscribed, SID}, Acc) ->
|
||||||
[SID | Acc];
|
[SID | Acc];
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@ -2944,15 +2944,15 @@ get_options_helper(JID, Lang, Node, NodeId, SubId, Type) ->
|
|||||||
{_, []} ->
|
{_, []} ->
|
||||||
{error, extended_error('not-acceptable', "not-subscribed")};
|
{error, extended_error('not-acceptable', "not-subscribed")};
|
||||||
{[], [SID]} ->
|
{[], [SID]} ->
|
||||||
read_sub(Subscriber, Node, NodeId, SID, Lang);
|
read_sub(Subscriber, Node, Nidx, SID, Lang);
|
||||||
{[], _} ->
|
{[], _} ->
|
||||||
{error, extended_error('not-acceptable', "subid-required")};
|
{error, extended_error('not-acceptable', "subid-required")};
|
||||||
{_, _} ->
|
{_, _} ->
|
||||||
read_sub(Subscriber, Node, NodeId, SubId, Lang)
|
read_sub(Subscriber, Node, Nidx, SubId, Lang)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeId, SubId, Lang) ->
|
read_sub(Subscriber, Node, Nidx, SubId, Lang) ->
|
||||||
case pubsub_subscription:get_subscription(Subscriber, NodeId, SubId) of
|
case pubsub_subscription:get_subscription(Subscriber, Nidx, SubId) of
|
||||||
{result, #pubsub_subscription{options = Options}} ->
|
{result, #pubsub_subscription{options = Options}} ->
|
||||||
{result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
{result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
||||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||||
@ -2986,7 +2986,7 @@ set_options(Host, Node, JID, SubId, Configuration) ->
|
|||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_options_helper(Configuration, JID, NodeId, SubId, Type) ->
|
set_options_helper(Configuration, JID, Nidx, SubId, Type) ->
|
||||||
SubOpts = case pubsub_subscription:parse_options_xform(Configuration) of
|
SubOpts = case pubsub_subscription:parse_options_xform(Configuration) of
|
||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
@ -2997,7 +2997,7 @@ set_options_helper(Configuration, JID, NodeId, SubId, Type) ->
|
|||||||
_ -> exmpp_jid:make("", "", "") %% TODO, check if use <<>> instead of ""
|
_ -> exmpp_jid:make("", "", "") %% TODO, check if use <<>> instead of ""
|
||||||
end,
|
end,
|
||||||
{result, Subs} = node_call(Type, get_subscriptions,
|
{result, Subs} = node_call(Type, get_subscriptions,
|
||||||
[NodeId, Subscriber]),
|
[Nidx, Subscriber]),
|
||||||
SubIds = lists:foldl(fun({subscribed, SID}, Acc) ->
|
SubIds = lists:foldl(fun({subscribed, SID}, Acc) ->
|
||||||
[SID | Acc];
|
[SID | Acc];
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@ -3007,19 +3007,19 @@ set_options_helper(Configuration, JID, NodeId, SubId, Type) ->
|
|||||||
{_, []} ->
|
{_, []} ->
|
||||||
{error, extended_error('not-acceptable', "not-subscribed")};
|
{error, extended_error('not-acceptable', "not-subscribed")};
|
||||||
{[], [SID]} ->
|
{[], [SID]} ->
|
||||||
write_sub(Subscriber, NodeId, SID, SubOpts);
|
write_sub(Subscriber, Nidx, SID, SubOpts);
|
||||||
{[], _} ->
|
{[], _} ->
|
||||||
{error, extended_error('not-acceptable', "subid-required")};
|
{error, extended_error('not-acceptable', "subid-required")};
|
||||||
{_, _} ->
|
{_, _} ->
|
||||||
write_sub(Subscriber, NodeId, SubId, SubOpts)
|
write_sub(Subscriber, Nidx, SubId, SubOpts)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
write_sub(_Subscriber, _NodeId, _SubId, invalid) ->
|
write_sub(_Subscriber, _Nidx, _SubId, invalid) ->
|
||||||
{error, extended_error('bad-request', "invalid-options")};
|
{error, extended_error('bad-request', "invalid-options")};
|
||||||
write_sub(_Subscriber, _NodeID, _SubID, []) ->
|
write_sub(_Subscriber, _Nidx, _SubId, []) ->
|
||||||
{result, []};
|
{result, []};
|
||||||
write_sub(Subscriber, NodeId, SubId, Options) ->
|
write_sub(Subscriber, Nidx, SubId, Options) ->
|
||||||
case pubsub_subscription:set_subscription(Subscriber, NodeId, SubId, Options) of
|
case pubsub_subscription:set_subscription(Subscriber, Nidx, SubId, Options) of
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
{result, []};
|
{result, []};
|
||||||
{error, _} ->
|
{error, _} ->
|
||||||
@ -3606,18 +3606,18 @@ node_subscriptions_full(Host, Node, NotifyType) ->
|
|||||||
{_, JIDSubs} = lists:foldl(DepthsToDeliver, {[], []}, SubsByDepth),
|
{_, JIDSubs} = lists:foldl(DepthsToDeliver, {[], []}, SubsByDepth),
|
||||||
JIDSubs.
|
JIDSubs.
|
||||||
|
|
||||||
sub_with_options(#pubsub_node{type = Type, id = NodeId}) ->
|
sub_with_options(#pubsub_node{type = Type, idx = Nidx}) ->
|
||||||
case node_call(Type, get_node_subscriptions, [NodeId]) of
|
case node_call(Type, get_node_subscriptions, [Nidx]) of
|
||||||
{result, Subs} ->
|
{result, Subs} ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun({JID, subscribed, SubId}, Acc) -> [sub_with_options(JID, NodeId, SubId) | Acc];
|
fun({JID, subscribed, SubId}, Acc) -> [sub_with_options(JID, Nidx, SubId) | Acc];
|
||||||
(_, Acc) -> Acc
|
(_, Acc) -> Acc
|
||||||
end, [], Subs);
|
end, [], Subs);
|
||||||
_ ->
|
_ ->
|
||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
sub_with_options(JID, NodeId, SubId) ->
|
sub_with_options(JID, Nidx, SubId) ->
|
||||||
case pubsub_subscription:read_subscription(JID, NodeId, SubId) of
|
case pubsub_subscription:read_subscription(JID, Nidx, SubId) of
|
||||||
#pubsub_subscription{options = Options} -> {JID, SubId, Options};
|
#pubsub_subscription{options = Options} -> {JID, SubId, Options};
|
||||||
_ -> {JID, SubId, []}
|
_ -> {JID, SubId, []}
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user