mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-29 14:37:44 +02:00
Add pubsub#type node config (EJAB-1083)
This commit is contained in:
parent
0964724b2a
commit
46ac8f97eb
@ -2073,7 +2073,8 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
|||||||
PayloadMaxSize = get_option(Options, max_payload_size),
|
PayloadMaxSize = get_option(Options, max_payload_size),
|
||||||
InvalidNS = case get_option(Options, type) of
|
InvalidNS = case get_option(Options, type) of
|
||||||
false -> false;
|
false -> false;
|
||||||
ConfiguredNS -> ConfiguredNS =/= PayloadNS
|
[[]] -> false;
|
||||||
|
[ConfiguredNS] -> ConfiguredNS =/= PayloadNS
|
||||||
end,
|
end,
|
||||||
% pubsub#deliver_payloads true
|
% pubsub#deliver_payloads true
|
||||||
% pubsub#persist_items true -> 1 item; false -> 0 item
|
% pubsub#persist_items true -> 1 item; false -> 0 item
|
||||||
@ -2089,6 +2090,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
|||||||
{error, extended_error('bad-request', "payload-required")};
|
{error, extended_error('bad-request', "payload-required")};
|
||||||
(PayloadCount > 1) or (PayloadCount == 0) or InvalidNS ->
|
(PayloadCount > 1) or (PayloadCount == 0) or InvalidNS ->
|
||||||
%% Entity attempts to publish item with multiple payload elements
|
%% Entity attempts to publish item with multiple payload elements
|
||||||
|
%% or with wrong payload NS
|
||||||
{error, extended_error('bad-request', "invalid-payload")};
|
{error, extended_error('bad-request', "invalid-payload")};
|
||||||
(DeliverPayloads == 0) and (PersistItems == 0) and (PayloadSize > 0) ->
|
(DeliverPayloads == 0) and (PersistItems == 0) and (PayloadSize > 0) ->
|
||||||
%% Publisher attempts to publish to transient notification node with item
|
%% Publisher attempts to publish to transient notification node with item
|
||||||
@ -3486,7 +3488,8 @@ get_configure_xfields(_Type, Options, Lang, Groups) ->
|
|||||||
?ALIST_CONFIG_FIELD("When to send the last published item", send_last_published_item,
|
?ALIST_CONFIG_FIELD("When to send the last published item", send_last_published_item,
|
||||||
[never, on_sub, on_sub_and_presence]),
|
[never, on_sub, on_sub_and_presence]),
|
||||||
?BOOL_CONFIG_FIELD("Only deliver notifications to available users", presence_based_delivery),
|
?BOOL_CONFIG_FIELD("Only deliver notifications to available users", presence_based_delivery),
|
||||||
?NLIST_CONFIG_FIELD("The collections with which a node is affiliated", collection)
|
?NLIST_CONFIG_FIELD("The collections with which a node is affiliated", collection),
|
||||||
|
?STRING_CONFIG_FIELD("The type of node data, usually specified by the namespace of the payload (if any)", type)
|
||||||
].
|
].
|
||||||
|
|
||||||
%%<p>There are several reasons why the node configuration request might fail:</p>
|
%%<p>There are several reasons why the node configuration request might fail:</p>
|
||||||
|
@ -1892,7 +1892,8 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
|||||||
PayloadMaxSize = get_option(Options, max_payload_size),
|
PayloadMaxSize = get_option(Options, max_payload_size),
|
||||||
InvalidNS = case get_option(Options, type) of
|
InvalidNS = case get_option(Options, type) of
|
||||||
false -> false;
|
false -> false;
|
||||||
ConfiguredNS -> ConfiguredNS =/= PayloadNS
|
[[]] -> false;
|
||||||
|
[ConfiguredNS] -> ConfiguredNS =/= PayloadNS
|
||||||
end,
|
end,
|
||||||
% pubsub#deliver_payloads true
|
% pubsub#deliver_payloads true
|
||||||
% pubsub#persist_items true -> 1 item; false -> 0 item
|
% pubsub#persist_items true -> 1 item; false -> 0 item
|
||||||
@ -1908,6 +1909,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
|||||||
{error, extended_error('bad-request', "payload-required")};
|
{error, extended_error('bad-request', "payload-required")};
|
||||||
(PayloadCount > 1) or (PayloadCount == 0) or InvalidNS ->
|
(PayloadCount > 1) or (PayloadCount == 0) or InvalidNS ->
|
||||||
%% Entity attempts to publish item with multiple payload elements
|
%% Entity attempts to publish item with multiple payload elements
|
||||||
|
%% or with wrong payload NS
|
||||||
{error, extended_error('bad-request', "invalid-payload")};
|
{error, extended_error('bad-request', "invalid-payload")};
|
||||||
(DeliverPayloads == 0) and (PersistItems == 0) and (PayloadSize > 0) ->
|
(DeliverPayloads == 0) and (PersistItems == 0) and (PayloadSize > 0) ->
|
||||||
%% Publisher attempts to publish to transient notification node with item
|
%% Publisher attempts to publish to transient notification node with item
|
||||||
@ -3324,7 +3326,8 @@ get_configure_xfields(_Type, Options, Lang, Groups) ->
|
|||||||
?ALIST_CONFIG_FIELD("When to send the last published item", send_last_published_item,
|
?ALIST_CONFIG_FIELD("When to send the last published item", send_last_published_item,
|
||||||
[never, on_sub, on_sub_and_presence]),
|
[never, on_sub, on_sub_and_presence]),
|
||||||
?BOOL_CONFIG_FIELD("Only deliver notifications to available users", presence_based_delivery),
|
?BOOL_CONFIG_FIELD("Only deliver notifications to available users", presence_based_delivery),
|
||||||
?NLIST_CONFIG_FIELD("The collections with which a node is affiliated", collection)
|
?NLIST_CONFIG_FIELD("The collections with which a node is affiliated", collection),
|
||||||
|
?STRING_CONFIG_FIELD("The type of node data, usually specified by the namespace of the payload (if any)", type)
|
||||||
].
|
].
|
||||||
|
|
||||||
%%<p>There are several reasons why the node configuration request might fail:</p>
|
%%<p>There are several reasons why the node configuration request might fail:</p>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--- mod_pubsub.erl 2010-05-12 13:53:23.000000000 +0200
|
--- mod_pubsub.erl 2010-05-12 14:49:39.000000000 +0200
|
||||||
+++ mod_pubsub_odbc.erl 2010-05-12 13:53:48.000000000 +0200
|
+++ mod_pubsub_odbc.erl 2010-05-12 14:50:41.000000000 +0200
|
||||||
@@ -42,7 +42,7 @@
|
@@ -42,7 +42,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.
|
||||||
@ -502,7 +502,7 @@
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
@@ -2280,7 +2099,7 @@
|
@@ -2282,7 +2101,7 @@
|
||||||
%% <p>The permission are not checked in this function.</p>
|
%% <p>The permission are not checked in this function.</p>
|
||||||
%% @todo We probably need to check that the user doing the query has the right
|
%% @todo We probably need to check that the user doing the query has the right
|
||||||
%% to read the items.
|
%% to read the items.
|
||||||
@ -511,7 +511,7 @@
|
|||||||
MaxItems =
|
MaxItems =
|
||||||
if
|
if
|
||||||
SMaxItems == "" -> get_max_items_node(Host);
|
SMaxItems == "" -> get_max_items_node(Host);
|
||||||
@@ -2319,11 +2138,11 @@
|
@@ -2321,11 +2140,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From,
|
[NodeId, From,
|
||||||
AccessModel, PresenceSubscription, RosterGroup,
|
AccessModel, PresenceSubscription, RosterGroup,
|
||||||
@ -525,7 +525,7 @@
|
|||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] ->
|
[] ->
|
||||||
Items;
|
Items;
|
||||||
@@ -2336,7 +2155,7 @@
|
@@ -2338,7 +2157,7 @@
|
||||||
%% number of items sent to MaxItems:
|
%% number of items sent to MaxItems:
|
||||||
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
||||||
@ -534,7 +534,7 @@
|
|||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
@@ -2368,17 +2187,29 @@
|
@@ -2370,17 +2189,29 @@
|
||||||
%% @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, NodeId, Type, LJID, last) ->
|
||||||
@ -571,7 +571,7 @@
|
|||||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
send_items(Host, Node, NodeId, 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, [NodeId, LJID]) of
|
||||||
{result, []} ->
|
{result, []} ->
|
||||||
@@ -2458,9 +2289,8 @@
|
@@ -2460,9 +2291,8 @@
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
@ -583,7 +583,7 @@
|
|||||||
{result, {_, Affiliations}} ->
|
{result, {_, Affiliations}} ->
|
||||||
Entities = lists:flatmap(
|
Entities = lists:flatmap(
|
||||||
fun({_, none}) -> [];
|
fun({_, none}) -> [];
|
||||||
@@ -2494,7 +2324,7 @@
|
@@ -2496,7 +2326,7 @@
|
||||||
_:_ -> error
|
_:_ -> error
|
||||||
end,
|
end,
|
||||||
Affiliation = string_to_affiliation(
|
Affiliation = string_to_affiliation(
|
||||||
@ -592,7 +592,7 @@
|
|||||||
if
|
if
|
||||||
(JID == error) or
|
(JID == error) or
|
||||||
(Affiliation == false) ->
|
(Affiliation == false) ->
|
||||||
@@ -2509,29 +2339,13 @@
|
@@ -2511,29 +2341,13 @@
|
||||||
error ->
|
error ->
|
||||||
{error, 'bad-request'};
|
{error, 'bad-request'};
|
||||||
_ ->
|
_ ->
|
||||||
@ -626,7 +626,7 @@
|
|||||||
end, Entities),
|
end, Entities),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2565,7 +2379,7 @@
|
@@ -2567,7 +2381,7 @@
|
||||||
J -> jlib:short_jid(J)
|
J -> jlib:short_jid(J)
|
||||||
catch
|
catch
|
||||||
_ ->
|
_ ->
|
||||||
@ -635,7 +635,7 @@
|
|||||||
end,
|
end,
|
||||||
{result, Subs} = node_call(Type, get_subscriptions,
|
{result, Subs} = node_call(Type, get_subscriptions,
|
||||||
[NodeID, Subscriber]),
|
[NodeID, Subscriber]),
|
||||||
@@ -2586,14 +2400,14 @@
|
@@ -2588,14 +2402,14 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||||
@ -653,7 +653,7 @@
|
|||||||
children = [XdataEl]},
|
children = [XdataEl]},
|
||||||
PubsubEl = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [OptionsEl]},
|
PubsubEl = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [OptionsEl]},
|
||||||
{result, PubsubEl}
|
{result, PubsubEl}
|
||||||
@@ -2617,14 +2431,14 @@
|
@@ -2619,14 +2433,14 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||||
@ -670,7 +670,7 @@
|
|||||||
end,
|
end,
|
||||||
{result, Subs} = node_call(Type, get_subscriptions,
|
{result, Subs} = node_call(Type, get_subscriptions,
|
||||||
[NodeID, Subscriber]),
|
[NodeID, Subscriber]),
|
||||||
@@ -2647,7 +2461,7 @@
|
@@ -2649,7 +2463,7 @@
|
||||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||||
{error, extended_error('bad-request', "invalid-options")};
|
{error, extended_error('bad-request', "invalid-options")};
|
||||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||||
@ -679,7 +679,7 @@
|
|||||||
{error, notfound} ->
|
{error, notfound} ->
|
||||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
@@ -2820,8 +2634,8 @@
|
@@ -2822,8 +2636,8 @@
|
||||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||||
ejabberd_router:route(service_jid(Host), JID, Stanza)
|
ejabberd_router:route(service_jid(Host), JID, Stanza)
|
||||||
end,
|
end,
|
||||||
@ -690,7 +690,7 @@
|
|||||||
true ->
|
true ->
|
||||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
|
|
||||||
@@ -3162,7 +2976,7 @@
|
@@ -3164,7 +2978,7 @@
|
||||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||||
end,
|
end,
|
||||||
@ -699,7 +699,7 @@
|
|||||||
{result, CollSubs} -> CollSubs;
|
{result, CollSubs} -> CollSubs;
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
@@ -3176,9 +2990,9 @@
|
@@ -3178,9 +2992,9 @@
|
||||||
|
|
||||||
get_options_for_subs(NodeID, Subs) ->
|
get_options_for_subs(NodeID, Subs) ->
|
||||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||||
@ -711,7 +711,7 @@
|
|||||||
_ -> Acc
|
_ -> Acc
|
||||||
end;
|
end;
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@@ -3400,6 +3214,30 @@
|
@@ -3402,6 +3216,30 @@
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -742,7 +742,7 @@
|
|||||||
%% @spec (Host, Options) -> MaxItems
|
%% @spec (Host, Options) -> MaxItems
|
||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Options = [Option]
|
%% Options = [Option]
|
||||||
@@ -3801,7 +3639,13 @@
|
@@ -3804,7 +3642,13 @@
|
||||||
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,
|
||||||
@ -757,7 +757,7 @@
|
|||||||
|
|
||||||
%% @doc <p>node plugin call.</p>
|
%% @doc <p>node plugin call.</p>
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
@@ -3821,13 +3665,13 @@
|
@@ -3824,13 +3668,13 @@
|
||||||
|
|
||||||
node_action(Host, Type, Function, Args) ->
|
node_action(Host, Type, Function, Args) ->
|
||||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||||
@ -773,7 +773,7 @@
|
|||||||
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
|
||||||
@@ -3840,8 +3684,15 @@
|
@@ -3843,8 +3687,15 @@
|
||||||
end
|
end
|
||||||
end, Trans).
|
end, Trans).
|
||||||
|
|
||||||
@ -791,7 +791,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};
|
||||||
@@ -3849,6 +3700,15 @@
|
@@ -3852,6 +3703,15 @@
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||||
{error, 'internal-server-error'};
|
{error, 'internal-server-error'};
|
||||||
@ -807,7 +807,7 @@
|
|||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||||
{error, 'internal-server-error'};
|
{error, 'internal-server-error'};
|
||||||
@@ -3857,6 +3717,16 @@
|
@@ -3860,6 +3720,16 @@
|
||||||
{error, 'internal-server-error'}
|
{error, 'internal-server-error'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -824,7 +824,7 @@
|
|||||||
%%%% helpers
|
%%%% helpers
|
||||||
|
|
||||||
%% Add pubsub-specific error element
|
%% Add pubsub-specific error element
|
||||||
@@ -3945,7 +3815,7 @@
|
@@ -3948,7 +3818,7 @@
|
||||||
%% If the sender Server equals Host, the message comes from the Pubsub server
|
%% If the sender Server equals Host, the message comes from the Pubsub server
|
||||||
Host -> allow;
|
Host -> allow;
|
||||||
%% Else, the message comes from PEP
|
%% Else, the message comes from PEP
|
||||||
|
Loading…
Reference in New Issue
Block a user