diff --git a/src/node_buddy.erl b/src/node_buddy.erl deleted file mode 100644 index a975cb3eb..000000000 --- a/src/node_buddy.erl +++ /dev/null @@ -1,182 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_buddy.erl -%%% Author : Christophe Romain -%%% Purpose : -%%% Created : 1 Dec 2007 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_buddy). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_flat:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_flat:terminate(Host, ServerHost). - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, true}, - {purge_offline, false}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, presence}, - {roster_groups_allowed, []}, - {publish_model, publishers}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, never}, - {deliver_notifications, true}, - {presence_based_delivery, false}, - {itemreply, none}]. - -features() -> - [<<"create-nodes">>, - <<"delete-nodes">>, - <<"delete-items">>, - <<"instant-nodes">>, - <<"item-ids">>, - <<"outcast-affiliation">>, - <<"persistent-items">>, - <<"multi-items">>, - <<"publish">>, - <<"purge-nodes">>, - <<"retract-items">>, - <<"retrieve-affiliations">>, - <<"retrieve-items">>, - <<"retrieve-subscriptions">>, - <<"subscribe">>, - <<"subscription-notifications">>]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_flat:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat:get_state(Nidx, JID). - -set_state(State) -> - node_flat:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_flat:node_to_path(Node). - -path_to_node(Path) -> - node_flat:path_to_node(Path). diff --git a/src/node_club.erl b/src/node_club.erl deleted file mode 100644 index 953aca117..000000000 --- a/src/node_club.erl +++ /dev/null @@ -1,181 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_club.erl -%%% Author : Christophe Romain -%%% Purpose : -%%% Created : 1 Dec 2007 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_club). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_flat:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_flat:terminate(Host, ServerHost). - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, true}, - {purge_offline, false}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, authorize}, - {roster_groups_allowed, []}, - {publish_model, publishers}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, never}, - {deliver_notifications, true}, - {presence_based_delivery, false}, - {itemreply, none}]. - -features() -> - [<<"create-nodes">>, - <<"delete-nodes">>, - <<"delete-items">>, - <<"instant-nodes">>, - <<"outcast-affiliation">>, - <<"persistent-items">>, - <<"multi-items">>, - <<"publish">>, - <<"purge-nodes">>, - <<"retract-items">>, - <<"retrieve-affiliations">>, - <<"retrieve-items">>, - <<"retrieve-subscriptions">>, - <<"subscribe">>, - <<"subscription-notifications">>]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_flat:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat:get_state(Nidx, JID). - -set_state(State) -> - node_flat:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_flat:node_to_path(Node). - -path_to_node(Path) -> - node_flat:path_to_node(Path). diff --git a/src/node_dag.erl b/src/node_dag.erl deleted file mode 100644 index 03633ef1e..000000000 --- a/src/node_dag.erl +++ /dev/null @@ -1,168 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_dag.erl -%%% Author : Brian Cully -%%% Purpose : experimental support of XEP-248 -%%% Created : 15 Jun 2009 by Brian Cully -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_dag). --behaviour(gen_pubsub_node). --author('bjc@kublai.com'). - --include("pubsub.hrl"). --include("xmpp.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_hometree:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_hometree:terminate(Host, ServerHost). - -options() -> - [{node_type, leaf} | node_hometree:options()]. - -features() -> - [<<"multi-collection">> | node_hometree:features()]. - -create_node_permission(_Host, _ServerHost, _Node, _ParentNode, _Owner, _Access) -> - {result, true}. - -create_node(Nidx, Owner) -> - node_hometree:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_hometree:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_hometree:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_hometree:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - case nodetree_dag:get_node(Nidx) of - #pubsub_node{options = Options} -> - case find_opt(node_type, Options) of - collection -> - Txt = <<"Publishing items to collection node is not allowed">>, - {error, mod_pubsub:extended_error( - xmpp:err_not_allowed(Txt, ejabberd_option:language()), - mod_pubsub:err_unsupported('publish'))}; - _ -> - node_hometree:publish_item(Nidx, Publisher, Model, - MaxItems, ItemId, Payload, PubOpts) - end; - Err -> Err - end. - -find_opt(_, []) -> false; -find_opt(Option, [{Option, Value} | _]) -> Value; -find_opt(Option, [_ | T]) -> find_opt(Option, T). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_hometree:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_hometree:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_hometree:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_hometree:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_hometree:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_hometree:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_hometree:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_hometree:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_hometree:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_hometree:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_hometree:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_hometree:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_hometree:get_states(Nidx). - -get_state(Nidx, JID) -> - node_hometree:get_state(Nidx, JID). - -set_state(State) -> - node_hometree:set_state(State). - -get_items(Nidx, From, RSM) -> - node_hometree:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_hometree:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_hometree:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_hometree:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_hometree:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_hometree:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_hometree:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_hometree:node_to_path(Node). - -path_to_node(Path) -> - node_hometree:path_to_node(Path). diff --git a/src/node_dispatch.erl b/src/node_dispatch.erl deleted file mode 100644 index d0c1b6165..000000000 --- a/src/node_dispatch.erl +++ /dev/null @@ -1,195 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_dispatch.erl -%%% Author : Christophe Romain -%%% Purpose : Publish item to node and all child subnodes -%%% Created : 1 Dec 2007 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - -%%% @doc

The {@module} module is a PubSub plugin whose -%%% goal is to republished each published item to all its children.

-%%%

Users cannot subscribe to this node, but are supposed to subscribe to -%%% its children.

-%%% This module can not work with virtual nodetree - --module(node_dispatch). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). --include("xmpp.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_hometree:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_hometree:terminate(Host, ServerHost). - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, true}, - {purge_offline, false}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, presence}, - {roster_groups_allowed, []}, - {publish_model, publishers}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, never}, - {deliver_notifications, true}, - {presence_based_delivery, false}, - {itemreply, none}]. - -features() -> - [<<"create-nodes">>, - <<"delete-nodes">>, - <<"instant-nodes">>, - <<"outcast-affiliation">>, - <<"persistent-items">>, - <<"multi-items">>, - <<"publish">>, - <<"retrieve-items">>]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_hometree:create_node(Nidx, Owner). - -delete_node(Nodes) -> - node_hometree:delete_node(Nodes). - -subscribe_node(_Nidx, _Sender, _Subscriber, _AccessModel, _SendLast, _PresenceSubscription, - _RosterGroup, _Options) -> - {error, mod_pubsub:extended_error(xmpp:err_feature_not_implemented(), - mod_pubsub:err_unsupported('subscribe'))}. - -unsubscribe_node(_Nidx, _Sender, _Subscriber, _SubId) -> - {error, mod_pubsub:extended_error(xmpp:err_feature_not_implemented(), - mod_pubsub:err_unsupported('subscribe'))}. - -publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload, - PubOpts) -> - case nodetree_tree:get_node(Nidx) of - #pubsub_node{nodeid = {Host, Node}} -> - lists:foreach(fun (SubNode) -> - node_hometree:publish_item(SubNode#pubsub_node.id, - Publisher, PublishModel, MaxItems, - ItemId, Payload, PubOpts) - end, - nodetree_tree:get_subnodes(Host, Node, Publisher)), - {result, {default, broadcast, []}}; - Error -> - Error - end. - -remove_extra_items(_Nidx, _MaxItems, ItemIds) -> - {result, {ItemIds, []}}. - -delete_item(_Nidx, _Publisher, _PublishModel, _ItemId) -> - {error, mod_pubsub:extended_error(xmpp:err_feature_not_implemented(), - mod_pubsub:err_unsupported('delete-items'))}. - -purge_node(_Nidx, _Owner) -> - {error, mod_pubsub:extended_error(xmpp:err_feature_not_implemented(), - mod_pubsub:err_unsupported('purge-nodes'))}. - -get_entity_affiliations(_Host, _Owner) -> - {result, []}. - -get_node_affiliations(_Nidx) -> - {result, []}. - -get_affiliation(_Nidx, _Owner) -> - {result, none}. - -set_affiliation(Nidx, Owner, Affiliation) -> - node_hometree:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(_Host, _Owner) -> - {result, []}. - -get_node_subscriptions(Nidx) -> - node_hometree:get_node_subscriptions(Nidx). - -get_subscriptions(_Nidx, _Owner) -> - {result, []}. - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_hometree:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_hometree:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_hometree:get_states(Nidx). - -get_state(Nidx, JID) -> - node_hometree:get_state(Nidx, JID). - -set_state(State) -> - node_hometree:set_state(State). - -get_items(Nidx, From, RSM) -> - node_hometree:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_hometree:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_hometree:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_hometree:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_hometree:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_hometree:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_hometree:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_hometree:node_to_path(Node). - -path_to_node(Path) -> - node_hometree:path_to_node(Path). diff --git a/src/node_hometree.erl b/src/node_hometree.erl deleted file mode 100644 index c55c696f4..000000000 --- a/src/node_hometree.erl +++ /dev/null @@ -1,180 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_hometree.erl -%%% Author : Christophe Romain -%%% Purpose : Standard tree ordered node plugin -%%% Created : 1 Dec 2007 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_hometree). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_flat:init(Host, ServerHost, Opts), - Owner = mod_pubsub:service_jid(Host), - mod_pubsub:create_node(Host, ServerHost, <<"/home">>, Owner, <<"hometree">>), - mod_pubsub:create_node(Host, ServerHost, <<"/home/", ServerHost/binary>>, Owner, <<"hometree">>), - ok. - -terminate(Host, ServerHost) -> - node_flat:terminate(Host, ServerHost). - -options() -> - node_flat:options(). - -features() -> - node_flat:features(). - -%% @doc Checks if the current user has the permission to create the requested node -%%

In hometree node, the permission is decided by the place in the -%% hierarchy where the user is creating the node. The access parameter is also -%% checked. This parameter depends on the value of the -%% access_createnode ACL value in ejabberd config file.

-%%

This function also check that node can be created as a children of its -%% parent node

-create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) -> - LOwner = jid:tolower(Owner), - {User, Server, _Resource} = LOwner, - Allowed = case LOwner of - {<<"">>, Host, <<"">>} -> - true; % pubsub service always allowed - _ -> - case acl:match_rule(ServerHost, Access, LOwner) of - allow -> - case node_to_path(Node) of - [<<"home">>, Server, User | _] -> true; - _ -> false - end; - _ -> false - end - end, - {result, Allowed}. - -create_node(Nidx, Owner) -> - node_flat:create_node(Nidx, Owner). - -delete_node(Nodes) -> - node_flat:delete_node(Nodes). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat:subscribe_node(Nidx, Sender, Subscriber, - AccessModel, SendLast, PresenceSubscription, - RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat:get_state(Nidx, JID). - -set_state(State) -> - node_flat:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat:get_item_name(Host, Node, Id). - -%% @doc

Return the path of the node.

-node_to_path(Node) -> - str:tokens(Node, <<"/">>). - -path_to_node([]) -> <<>>; -path_to_node(Path) -> iolist_to_binary(str:join([<<"">> | Path], <<"/">>)). - diff --git a/src/node_hometree_sql.erl b/src/node_hometree_sql.erl deleted file mode 100644 index 8e0a8f281..000000000 --- a/src/node_hometree_sql.erl +++ /dev/null @@ -1,159 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_hometree_sql.erl -%%% Author : Christophe Romain -%%% Purpose : Standard tree ordered node plugin with ODBC backend -%%% Created : 1 Dec 2007 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_hometree_sql). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1, - get_entity_subscriptions_for_send_last/2, get_last_items/3]). - -init(Host, ServerHost, Opts) -> - node_flat_sql:init(Host, ServerHost, Opts), - Owner = mod_pubsub:service_jid(Host), - mod_pubsub:create_node(Host, ServerHost, <<"/home">>, Owner, <<"hometree">>), - mod_pubsub:create_node(Host, ServerHost, <<"/home/", ServerHost/binary>>, Owner, <<"hometree">>), - ok. - -terminate(Host, ServerHost) -> - node_flat_sql:terminate(Host, ServerHost). - -options() -> - [{sql, true}, {rsm, true} | node_hometree:options()]. - -features() -> - [<<"rsm">> | node_hometree:features()]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat_sql:create_node(Nidx, Owner). - -delete_node(Nodes) -> - node_flat_sql:delete_node(Nodes). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat_sql:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat_sql:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat_sql:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat_sql:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat_sql:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat_sql:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat_sql:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat_sql:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat_sql:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat_sql:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat_sql:get_entity_subscriptions(Host, Owner). - -get_entity_subscriptions_for_send_last(Host, Owner) -> - node_flat_sql:get_entity_subscriptions_for_send_last(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat_sql:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat_sql:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat_sql:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat_sql:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat_sql:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat_sql:get_state(Nidx, JID). - -set_state(State) -> - node_flat_sql:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat_sql:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat_sql:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_item(Nidx, ItemId) -> - node_flat_sql:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat_sql:get_item(Nidx, ItemId, JID, - AccessModel, PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat_sql:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat_sql:get_item_name(Host, Node, Id). - -get_last_items(Nidx, From, Count) -> - node_flat_sql:get_last_items(Nidx, From, Count). - -node_to_path(Node) -> - node_hometree:node_to_path(Node). - -path_to_node(Path) -> - node_hometree:path_to_node(Path). - diff --git a/src/node_mb.erl b/src/node_mb.erl deleted file mode 100644 index 9042f27cf..000000000 --- a/src/node_mb.erl +++ /dev/null @@ -1,197 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_mb.erl -%%% Author : Eric Cestari -%%% Purpose : PEP microglobing experimentation -%%% Created : 25 Sep 2008 by Eric Cestari -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_mb). --behaviour(gen_pubsub_node). --author('ecestari@process-one.net'). - --include("pubsub.hrl"). - -%%% @doc The module {@module} is the pep microblog PubSub plugin. -%%%

To be used, mod_pubsub must be configured:

-%%% mod_pubsub:
-%%%   access_createnode: pubsub_createnode
-%%%   ignore_pep_from_offline: false
-%%%   plugins:
-%%%     - "flat"
-%%%     - "pep" # Requires mod_caps.
-%%%     - "mb"
-%%%   pep_mapping:
-%%%     "urn:xmpp:microblog:0": "mb"
-%%% 

-%%%

PubSub plugin nodes are using the {@link gen_pubsub_node} behaviour.

- --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_pep:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_pep:terminate(Host, ServerHost), ok. - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, false}, - {purge_offline, false}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, presence}, - {roster_groups_allowed, []}, - {publish_model, publishers}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, on_sub_and_presence}, - {deliver_notifications, true}, - {presence_based_delivery, true}, - {itemreply, none}]. - -features() -> - [<<"create-nodes">>, - <<"auto-create">>, - <<"auto-subscribe">>, - <<"delete-nodes">>, - <<"delete-items">>, - <<"filtered-notifications">>, - <<"modify-affiliations">>, - <<"outcast-affiliation">>, - <<"persistent-items">>, - <<"multi-items">>, - <<"publish">>, - <<"publish-options">>, - <<"purge-nodes">>, - <<"retract-items">>, - <<"retrieve-affiliations">>, - <<"retrieve-items">>, - <<"retrieve-subscriptions">>, - <<"subscribe">>]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_pep:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_pep:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_pep:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_pep:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_pep:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_pep:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_pep:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_pep:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_pep:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_pep:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_pep:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_pep:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_pep:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_pep:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_pep:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_pep:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_pep:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_pep:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_pep:get_states(Nidx). - -get_state(Nidx, JID) -> - node_pep:get_state(Nidx, JID). - -set_state(State) -> - node_pep:set_state(State). - -get_items(Nidx, From, RSM) -> - node_pep:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_pep:get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_pep:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_pep:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_pep:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_pep:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_pep:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_pep:node_to_path(Node). - -path_to_node(Path) -> - node_pep:path_to_node(Path). diff --git a/src/node_mb_sql.erl b/src/node_mb_sql.erl deleted file mode 100644 index bc06be24d..000000000 --- a/src/node_mb_sql.erl +++ /dev/null @@ -1,157 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_mb_sql.erl -%%% Author : Holger Weiss -%%% Purpose : PEP microblogging (XEP-0277) plugin with SQL backend -%%% Created : 6 Sep 2016 by Holger Weiss -%%% -%%% -%%% ejabberd, Copyright (C) 2016-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_mb_sql). --behaviour(gen_pubsub_node). --author('holger@zedat.fu-berlin.de'). - --include("pubsub.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1, get_entity_subscriptions_for_send_last/2, - get_last_items/3]). - -init(Host, ServerHost, Opts) -> - node_pep_sql:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_pep_sql:terminate(Host, ServerHost), ok. - -options() -> - [{sql, true}, {rsm, true} | node_mb:options()]. - -features() -> - [<<"rsm">> | node_mb:features()]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_pep_sql:create_node_permission(Host, ServerHost, Node, ParentNode, - Owner, Access). - -create_node(Nidx, Owner) -> - node_pep_sql:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_pep_sql:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options) -> - node_pep_sql:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_pep_sql:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_pep_sql:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_pep_sql:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_pep_sql:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_pep_sql:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_pep_sql:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_pep_sql:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_pep_sql:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_pep_sql:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_pep_sql:get_entity_subscriptions(Host, Owner). - -get_entity_subscriptions_for_send_last(Host, Owner) -> - node_pep_sql:get_entity_subscriptions_for_send_last(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_pep_sql:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_pep_sql:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_pep_sql:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_pep_sql:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_pep_sql:get_states(Nidx). - -get_state(Nidx, JID) -> - node_pep_sql:get_state(Nidx, JID). - -set_state(State) -> - node_pep_sql:set_state(State). - -get_items(Nidx, From, RSM) -> - node_pep_sql:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, - RSM) -> - node_pep_sql:get_items(Nidx, JID, AccessModel, PresenceSubscription, - RosterGroup, SubId, RSM). - -get_last_items(Nidx, JID, Count) -> - node_pep_sql:get_last_items(Nidx, JID, Count). - -get_item(Nidx, ItemId) -> - node_pep_sql:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, - SubId) -> - node_pep_sql:get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, - RosterGroup, SubId). - -set_item(Item) -> - node_pep_sql:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_pep_sql:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_pep_sql:node_to_path(Node). - -path_to_node(Path) -> - node_pep_sql:path_to_node(Path). diff --git a/src/node_mix.erl b/src/node_mix.erl deleted file mode 100644 index 4d2741a5e..000000000 --- a/src/node_mix.erl +++ /dev/null @@ -1,190 +0,0 @@ -%%%------------------------------------------------------------------- -%%% File : node_mix.erl -%%% Author : Evgeny Khramtsov -%%% Created : 8 Mar 2016 by Evgeny Khramtsov -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_mix). - --behaviour(gen_pubsub_node). - -%% API --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - --include("pubsub.hrl"). - -%%%=================================================================== -%%% API -%%%=================================================================== -init(Host, ServerHost, Opts) -> - node_flat:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_flat:terminate(Host, ServerHost). - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, true}, - {purge_offline, false}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, open}, - {roster_groups_allowed, []}, - {publish_model, open}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, never}, - {deliver_notifications, true}, - {broadcast_all_resources, true}, - {presence_based_delivery, false}, - {itemreply, none}]. - -features() -> - [<<"create-nodes">>, - <<"delete-nodes">>, - <<"delete-items">>, - <<"instant-nodes">>, - <<"item-ids">>, - <<"outcast-affiliation">>, - <<"persistent-items">>, - <<"multi-items">>, - <<"publish">>, - <<"purge-nodes">>, - <<"retract-items">>, - <<"retrieve-affiliations">>, - <<"retrieve-items">>, - <<"retrieve-subscriptions">>, - <<"subscribe">>, - <<"subscription-notifications">>]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_flat:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, - PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat:get_state(Nidx, JID). - -set_state(State) -> - node_flat:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_flat:node_to_path(Node). - -path_to_node(Path) -> - node_flat:path_to_node(Path). - -%%%=================================================================== -%%% Internal functions -%%%=================================================================== diff --git a/src/node_mix_sql.erl b/src/node_mix_sql.erl deleted file mode 100644 index 961d34da8..000000000 --- a/src/node_mix_sql.erl +++ /dev/null @@ -1,161 +0,0 @@ -%%%------------------------------------------------------------------- -%%% File : node_mix_sql.erl -%%% Author : Evgeny Khramtsov -%%% Created : 8 Mar 2016 by Evgeny Khramtsov -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_mix_sql). - --behaviour(gen_pubsub_node). - -%% API --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1, get_entity_subscriptions_for_send_last/2]). - --include("pubsub.hrl"). - -%%%=================================================================== -%%% API -%%%=================================================================== -init(Host, ServerHost, Opts) -> - node_flat_sql:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_flat_sql:terminate(Host, ServerHost). - -options() -> - [{sql, true}, {rsm, true} | node_mix:options()]. - -features() -> - [<<"rsm">> | node_mix:features()]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_flat_sql:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat_sql:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_flat_sql:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat_sql:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat_sql:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat_sql:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat_sql:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat_sql:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat_sql:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat_sql:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat_sql:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat_sql:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat_sql:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat_sql:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat_sql:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat_sql:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat_sql:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat_sql:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat_sql:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat_sql:get_state(Nidx, JID). - -set_state(State) -> - node_flat_sql:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat_sql:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat_sql:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat_sql:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat_sql:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat_sql:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat_sql:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat_sql:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_flat_sql:node_to_path(Node). - -path_to_node(Path) -> - node_flat_sql:path_to_node(Path). - -get_entity_subscriptions_for_send_last(Host, Owner) -> - node_flat_sql:get_entity_subscriptions_for_send_last(Host, Owner). - -%%%=================================================================== -%%% Internal functions -%%%=================================================================== diff --git a/src/node_online.erl b/src/node_online.erl deleted file mode 100644 index 0bdcb60c3..000000000 --- a/src/node_online.erl +++ /dev/null @@ -1,180 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_online.erl -%%% Author : Christophe Romain -%%% Purpose : Handle only online users, remove offline subscriptions and nodes -%%% Created : 15 Dec 2015 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_online). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). --include("jid.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - --export([user_offline/3]). - -init(Host, ServerHost, Opts) -> - node_flat:init(Host, ServerHost, Opts), - ejabberd_hooks:add(sm_remove_connection_hook, ServerHost, - ?MODULE, user_offline, 75), - ok. - -terminate(Host, ServerHost) -> - node_flat:terminate(Host, ServerHost), - ejabberd_hooks:delete(sm_remove_connection_hook, ServerHost, - ?MODULE, user_offline, 75), - ok. - --spec user_offline(ejabberd_sm:sid(), jid(), ejabberd_sm:info()) -> _. -user_offline(_SID, #jid{luser=LUser,lserver=LServer}, _Info) -> - mod_pubsub:remove_user(LUser, LServer). - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, false}, - {purge_offline, true}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, open}, - {roster_groups_allowed, []}, - {publish_model, publishers}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, on_sub_and_presence}, - {deliver_notifications, true}, - {presence_based_delivery, true}, - {itemreply, none}]. - -features() -> - node_flat:features(). - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_flat:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat:get_state(Nidx, JID). - -set_state(State) -> - node_flat:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_flat:node_to_path(Node). - -path_to_node(Path) -> - node_flat:path_to_node(Path). diff --git a/src/node_private.erl b/src/node_private.erl deleted file mode 100644 index d98669372..000000000 --- a/src/node_private.erl +++ /dev/null @@ -1,181 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_private.erl -%%% Author : Christophe Romain -%%% Purpose : -%%% Created : 1 Dec 2007 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_private). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_flat:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_flat:terminate(Host, ServerHost). - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, true}, - {purge_offline, false}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, whitelist}, - {roster_groups_allowed, []}, - {publish_model, publishers}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, never}, - {deliver_notifications, false}, - {presence_based_delivery, false}, - {itemreply, none}]. - -features() -> - [<<"create-nodes">>, - <<"delete-nodes">>, - <<"delete-items">>, - <<"instant-nodes">>, - <<"outcast-affiliation">>, - <<"persistent-items">>, - <<"multi-items">>, - <<"publish">>, - <<"purge-nodes">>, - <<"retract-items">>, - <<"retrieve-affiliations">>, - <<"retrieve-items">>, - <<"retrieve-subscriptions">>, - <<"subscribe">>, - <<"subscription-notifications">>]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_flat:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat:get_state(Nidx, JID). - -set_state(State) -> - node_flat:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_flat:node_to_path(Node). - -path_to_node(Path) -> - node_flat:path_to_node(Path). diff --git a/src/node_public.erl b/src/node_public.erl deleted file mode 100644 index 28dafa791..000000000 --- a/src/node_public.erl +++ /dev/null @@ -1,181 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : node_public.erl -%%% Author : Christophe Romain -%%% Purpose : -%%% Created : 1 Dec 2007 by Christophe Romain -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(node_public). --behaviour(gen_pubsub_node). --author('christophe.romain@process-one.net'). - --include("pubsub.hrl"). - --export([init/3, terminate/2, options/0, features/0, - create_node_permission/6, create_node/2, delete_node/1, - purge_node/2, subscribe_node/8, unsubscribe_node/4, - publish_item/7, delete_item/4, remove_extra_items/3, - get_entity_affiliations/2, get_node_affiliations/1, - get_affiliation/2, set_affiliation/3, - get_entity_subscriptions/2, get_node_subscriptions/1, - get_subscriptions/2, set_subscriptions/4, - get_pending_nodes/2, get_states/1, get_state/2, - set_state/1, get_items/7, get_items/3, get_item/7, - get_last_items/3, - get_item/2, set_item/1, get_item_name/3, node_to_path/1, - path_to_node/1]). - -init(Host, ServerHost, Opts) -> - node_flat:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - node_flat:terminate(Host, ServerHost). - -options() -> - [{deliver_payloads, true}, - {notify_config, false}, - {notify_delete, false}, - {notify_retract, true}, - {purge_offline, false}, - {persist_items, true}, - {max_items, ?MAXITEMS}, - {subscribe, true}, - {access_model, open}, - {roster_groups_allowed, []}, - {publish_model, publishers}, - {notification_type, headline}, - {max_payload_size, ?MAX_PAYLOAD_SIZE}, - {send_last_published_item, never}, - {deliver_notifications, true}, - {presence_based_delivery, false}, - {itemreply, none}]. - -features() -> - [<<"create-nodes">>, - <<"delete-nodes">>, - <<"delete-items">>, - <<"instant-nodes">>, - <<"outcast-affiliation">>, - <<"persistent-items">>, - <<"multi-items">>, - <<"publish">>, - <<"purge-nodes">>, - <<"retract-items">>, - <<"retrieve-affiliations">>, - <<"retrieve-items">>, - <<"retrieve-subscriptions">>, - <<"subscribe">>, - <<"subscription-notifications">>]. - -create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) -> - node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). - -create_node(Nidx, Owner) -> - node_flat:create_node(Nidx, Owner). - -delete_node(Removed) -> - node_flat:delete_node(Removed). - -subscribe_node(Nidx, Sender, Subscriber, AccessModel, - SendLast, PresenceSubscription, RosterGroup, Options) -> - node_flat:subscribe_node(Nidx, Sender, Subscriber, AccessModel, SendLast, - PresenceSubscription, RosterGroup, Options). - -unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> - node_flat:unsubscribe_node(Nidx, Sender, Subscriber, SubId). - -publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> - node_flat:publish_item(Nidx, Publisher, Model, MaxItems, ItemId, - Payload, PubOpts). - -remove_extra_items(Nidx, MaxItems, ItemIds) -> - node_flat:remove_extra_items(Nidx, MaxItems, ItemIds). - -delete_item(Nidx, Publisher, PublishModel, ItemId) -> - node_flat:delete_item(Nidx, Publisher, PublishModel, ItemId). - -purge_node(Nidx, Owner) -> - node_flat:purge_node(Nidx, Owner). - -get_entity_affiliations(Host, Owner) -> - node_flat:get_entity_affiliations(Host, Owner). - -get_node_affiliations(Nidx) -> - node_flat:get_node_affiliations(Nidx). - -get_affiliation(Nidx, Owner) -> - node_flat:get_affiliation(Nidx, Owner). - -set_affiliation(Nidx, Owner, Affiliation) -> - node_flat:set_affiliation(Nidx, Owner, Affiliation). - -get_entity_subscriptions(Host, Owner) -> - node_flat:get_entity_subscriptions(Host, Owner). - -get_node_subscriptions(Nidx) -> - node_flat:get_node_subscriptions(Nidx). - -get_subscriptions(Nidx, Owner) -> - node_flat:get_subscriptions(Nidx, Owner). - -set_subscriptions(Nidx, Owner, Subscription, SubId) -> - node_flat:set_subscriptions(Nidx, Owner, Subscription, SubId). - -get_pending_nodes(Host, Owner) -> - node_flat:get_pending_nodes(Host, Owner). - -get_states(Nidx) -> - node_flat:get_states(Nidx). - -get_state(Nidx, JID) -> - node_flat:get_state(Nidx, JID). - -set_state(State) -> - node_flat:set_state(State). - -get_items(Nidx, From, RSM) -> - node_flat:get_items(Nidx, From, RSM). - -get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, SubId, RSM) -> - node_flat:get_items(Nidx, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId, RSM). - -get_last_items(Nidx, From, Count) -> - node_flat:get_last_items(Nidx, From, Count). - -get_item(Nidx, ItemId) -> - node_flat:get_item(Nidx, ItemId). - -get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) -> - node_flat:get_item(Nidx, ItemId, JID, AccessModel, - PresenceSubscription, RosterGroup, SubId). - -set_item(Item) -> - node_flat:set_item(Item). - -get_item_name(Host, Node, Id) -> - node_flat:get_item_name(Host, Node, Id). - -node_to_path(Node) -> - node_flat:node_to_path(Node). - -path_to_node(Path) -> - node_flat:path_to_node(Path). diff --git a/src/nodetree_dag.erl b/src/nodetree_dag.erl deleted file mode 100644 index 7e31d7106..000000000 --- a/src/nodetree_dag.erl +++ /dev/null @@ -1,238 +0,0 @@ -%%%---------------------------------------------------------------------- -%%% File : nodetree_dag.erl -%%% Author : Brian Cully -%%% Purpose : experimental support of XEP-248 -%%% Created : 15 Jun 2009 by Brian Cully -%%% -%%% -%%% ejabberd, Copyright (C) 2002-2019 ProcessOne -%%% -%%% This program is free software; you can redistribute it and/or -%%% modify it under the terms of the GNU General Public License as -%%% published by the Free Software Foundation; either version 2 of the -%%% License, or (at your option) any later version. -%%% -%%% This program is distributed in the hope that it will be useful, -%%% but WITHOUT ANY WARRANTY; without even the implied warranty of -%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%%% General Public License for more details. -%%% -%%% You should have received a copy of the GNU General Public License along -%%% with this program; if not, write to the Free Software Foundation, Inc., -%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -%%% -%%%---------------------------------------------------------------------- - --module(nodetree_dag). --behaviour(gen_pubsub_nodetree). --author('bjc@kublai.com'). - --include_lib("stdlib/include/qlc.hrl"). - --include("pubsub.hrl"). --include("xmpp.hrl"). - --export([init/3, terminate/2, options/0, set_node/1, - get_node/3, get_node/2, get_node/1, get_nodes/2, - get_nodes/1, get_parentnodes/3, get_parentnodes_tree/3, - get_subnodes/3, get_subnodes_tree/3, create_node/6, - delete_node/2]). - - --define(DEFAULT_NODETYPE, leaf). --define(DEFAULT_PARENTS, []). --define(DEFAULT_CHILDREN, []). - -init(Host, ServerHost, Opts) -> - nodetree_tree:init(Host, ServerHost, Opts). - -terminate(Host, ServerHost) -> - nodetree_tree:terminate(Host, ServerHost). - -set_node(#pubsub_node{nodeid = {Key, _}, owners = Owners, options = Options} = Node) -> - Parents = find_opt(collection, ?DEFAULT_PARENTS, Options), - case validate_parentage(Key, Owners, Parents) of - true -> mnesia:write(Node#pubsub_node{parents = Parents}); - Other -> Other - end. - -create_node(Key, Node, Type, Owner, Options, Parents) -> - OwnerJID = jid:tolower(jid:remove_resource(Owner)), - case find_node(Key, Node) of - false -> - Nidx = pubsub_index:new(node), - N = #pubsub_node{nodeid = oid(Key, Node), id = Nidx, - type = Type, parents = Parents, owners = [OwnerJID], - options = Options}, - case set_node(N) of - ok -> {ok, Nidx}; - Other -> Other - end; - _ -> - {error, xmpp:err_conflict(<<"Node already exists">>, ejabberd_option:language())} - end. - -delete_node(Key, Node) -> - case find_node(Key, Node) of - false -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_option:language())}; - Record -> - lists:foreach(fun (#pubsub_node{options = Opts} = Child) -> - NewOpts = remove_config_parent(Node, Opts), - Parents = find_opt(collection, ?DEFAULT_PARENTS, NewOpts), - ok = mnesia:write(pubsub_node, - Child#pubsub_node{parents = Parents, - options = NewOpts}, - write) - end, - get_subnodes(Key, Node)), - pubsub_index:free(node, Record#pubsub_node.id), - mnesia:delete_object(pubsub_node, Record, write), - [Record] - end. - -options() -> - nodetree_tree:options(). - -get_node(Host, Node, _From) -> - get_node(Host, Node). - -get_node(Host, Node) -> - case find_node(Host, Node) of - false -> {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_option:language())}; - Record -> Record - end. - -get_node(Node) -> - nodetree_tree:get_node(Node). - -get_nodes(Key, From) -> - nodetree_tree:get_nodes(Key, From). - -get_nodes(Key) -> - nodetree_tree:get_nodes(Key). - -get_parentnodes(Host, Node, _From) -> - case find_node(Host, Node) of - false -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_option:language())}; - #pubsub_node{parents = Parents} -> - Q = qlc:q([N - || #pubsub_node{nodeid = {NHost, NNode}} = N - <- mnesia:table(pubsub_node), - Parent <- Parents, Host == NHost, Parent == NNode]), - qlc:e(Q) - end. - -get_parentnodes_tree(Host, Node, _From) -> - Pred = fun (NID, #pubsub_node{nodeid = {_, NNode}}) -> - NID == NNode - end, - Tr = fun (#pubsub_node{parents = Parents}) -> Parents - end, - traversal_helper(Pred, Tr, Host, [Node]). - -get_subnodes(Host, Node, _From) -> - get_subnodes(Host, Node). - -get_subnodes(Host, <<>>) -> - get_subnodes_helper(Host, <<>>); -get_subnodes(Host, Node) -> - case find_node(Host, Node) of - false -> {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_option:language())}; - _ -> get_subnodes_helper(Host, Node) - end. - -get_subnodes_helper(Host, Node) -> - Q = qlc:q([N - || #pubsub_node{nodeid = {NHost, _}, - parents = Parents} = - N - <- mnesia:table(pubsub_node), - Host == NHost, lists:member(Node, Parents)]), - qlc:e(Q). - -get_subnodes_tree(Host, Node, From) -> - Pred = fun (NID, #pubsub_node{parents = Parents}) -> - lists:member(NID, Parents) - end, - Tr = fun (#pubsub_node{nodeid = {_, N}}) -> [N] end, - traversal_helper(Pred, Tr, 1, Host, [Node], - [{0, [get_node(Host, Node, From)]}]). - -%%==================================================================== -%% Internal functions -%%==================================================================== -oid(Key, Name) -> {Key, Name}. - -%% Key = jlib:jid() | host() -%% Node = string() --spec find_node(Key :: mod_pubsub:hostPubsub(), Node :: mod_pubsub:nodeId()) -> - mod_pubsub:pubsubNode() | false. -find_node(Key, Node) -> - case mnesia:read(pubsub_node, oid(Key, Node), read) of - [] -> false; - [Node] -> Node - end. - -%% Key = jlib:jid() | host() -%% Default = term() -%% Options = [{Key = atom(), Value = term()}] -find_opt(Key, Default, Options) -> - case lists:keysearch(Key, 1, Options) of - {value, {Key, Val}} -> Val; - _ -> Default - end. - --spec traversal_helper(Pred :: fun(), Tr :: fun(), Host :: mod_pubsub:hostPubsub(), - Nodes :: [mod_pubsub:nodeId(),...]) -> - [{Depth::non_neg_integer(), - Nodes::[mod_pubsub:pubsubNode(),...]}]. - -traversal_helper(Pred, Tr, Host, Nodes) -> - traversal_helper(Pred, Tr, 0, Host, Nodes, []). - -traversal_helper(_Pred, _Tr, _Depth, _Host, [], Acc) -> - Acc; -traversal_helper(Pred, Tr, Depth, Host, Nodes, Acc) -> - Q = qlc:q([N - || #pubsub_node{nodeid = {NHost, _}} = N - <- mnesia:table(pubsub_node), - Node <- Nodes, Host == NHost, Pred(Node, N)]), - Nodes = qlc:e(Q), - IDs = lists:flatmap(Tr, Nodes), - traversal_helper(Pred, Tr, Depth + 1, Host, IDs, [{Depth, Nodes} | Acc]). - -remove_config_parent(Node, Options) -> - remove_config_parent(Node, Options, []). - -remove_config_parent(_Node, [], Acc) -> - lists:reverse(Acc); -remove_config_parent(Node, [{collection, Parents} | T], Acc) -> - remove_config_parent(Node, T, [{collection, lists:delete(Node, Parents)} | Acc]); -remove_config_parent(Node, [H | T], Acc) -> - remove_config_parent(Node, T, [H | Acc]). - --spec validate_parentage(Key :: mod_pubsub:hostPubsub(), Owners :: [ljid(),...], - Parent_Nodes :: [mod_pubsub:nodeId()]) -> - true | {error, stanza_error()}. - -validate_parentage(_Key, _Owners, []) -> - true; -validate_parentage(Key, Owners, [[] | T]) -> - validate_parentage(Key, Owners, T); -validate_parentage(Key, Owners, [<<>> | T]) -> - validate_parentage(Key, Owners, T); -validate_parentage(Key, Owners, [ParentID | T]) -> - case find_node(Key, ParentID) of - false -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_option:language())}; - #pubsub_node{owners = POwners, options = POptions} -> - NodeType = find_opt(node_type, ?DEFAULT_NODETYPE, POptions), - MutualOwners = [O || O <- Owners, PO <- POwners, O == PO], - case {MutualOwners, NodeType} of - {[], _} -> {error, xmpp:err_forbidden()}; - {_, collection} -> validate_parentage(Key, Owners, T); - {_, _} -> {error, xmpp:err_not_allowed()} - end - end.