Changeset

9158:37e814a680ab

mod_pubsub, mod_pep, util.pubsub: Move capability definitions into util.pubsub to avoid duplication
author Matthew Wild <mwild1@gmail.com>
date Wed, 08 Aug 2018 20:48:02 +0100
parents 9157:c517a219f2ac
children 9159:a0fd7064f4ac
files plugins/mod_pep.lua plugins/mod_pubsub/mod_pubsub.lua util/pubsub.lua
diffstat 3 files changed, 77 insertions(+), 157 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pep.lua	Wed Aug 08 20:40:44 2018 +0100
+++ b/plugins/mod_pep.lua	Wed Aug 08 20:48:02 2018 +0100
@@ -149,84 +149,6 @@
 		return service;
 	end
 	service = pubsub.new({
-		capabilities = {
-			restricted = {
-				be_subscribed = false;
-				be_unsubscribed = true;
-			};
-			none = {
-				create = false;
-				publish = false;
-				retract = false;
-				get_nodes = true;
-
-				subscribe = true;
-				unsubscribe = true;
-				get_subscription = true;
-				get_subscriptions = true;
-				get_items = true;
-
-				subscribe_other = false;
-				unsubscribe_other = false;
-				get_subscription_other = false;
-				get_subscriptions_other = false;
-
-				be_subscribed = true;
-				be_unsubscribed = true;
-
-				set_affiliation = false;
-			};
-			publisher = {
-				create = false;
-				publish = true;
-				retract = true;
-				get_nodes = true;
-				get_configuration = true;
-
-				subscribe = true;
-				unsubscribe = true;
-				get_subscription = true;
-				get_subscriptions = true;
-				get_items = true;
-
-				subscribe_other = false;
-				unsubscribe_other = false;
-				get_subscription_other = false;
-				get_subscriptions_other = false;
-
-				be_subscribed = true;
-				be_unsubscribed = true;
-
-				set_affiliation = false;
-			};
-			owner = {
-				create = true;
-				publish = true;
-				retract = true;
-				delete = true;
-				get_nodes = true;
-				configure = true;
-				get_configuration = true;
-
-				subscribe = true;
-				unsubscribe = true;
-				get_subscription = true;
-				get_subscriptions = true;
-				get_items = true;
-
-
-				subscribe_other = true;
-				unsubscribe_other = true;
-				get_subscription_other = true;
-				get_subscriptions_other = true;
-
-				be_subscribed = true;
-				be_unsubscribed = true;
-
-				set_affiliation = true;
-			};
-		};
-
 		node_defaults = {
 			["max_items"] = 1;
 			["persist_items"] = true;
--- a/plugins/mod_pubsub/mod_pubsub.lua	Wed Aug 08 20:40:44 2018 +0100
+++ b/plugins/mod_pubsub/mod_pubsub.lua	Wed Aug 08 20:48:02 2018 +0100
@@ -172,84 +172,6 @@
 	if module.reloading then return; end
 
 	set_service(pubsub.new({
-		capabilities = {
-			restricted = {
-				be_subscribed = false;
-				be_unsubscribed = true;
-			};
-			none = {
-				create = false;
-				publish = false;
-				retract = false;
-				get_nodes = true;
-
-				subscribe = true;
-				unsubscribe = true;
-				get_subscription = true;
-				get_subscriptions = true;
-				get_items = true;
-
-				subscribe_other = false;
-				unsubscribe_other = false;
-				get_subscription_other = false;
-				get_subscriptions_other = false;
-
-				be_subscribed = true;
-				be_unsubscribed = true;
-
-				set_affiliation = false;
-			};
-			publisher = {
-				create = false;
-				publish = true;
-				retract = true;
-				get_nodes = true;
-				get_configuration = true;
-
-				subscribe = true;
-				unsubscribe = true;
-				get_subscription = true;
-				get_subscriptions = true;
-				get_items = true;
-
-				subscribe_other = false;
-				unsubscribe_other = false;
-				get_subscription_other = false;
-				get_subscriptions_other = false;
-
-				be_subscribed = true;
-				be_unsubscribed = true;
-
-				set_affiliation = false;
-			};
-			owner = {
-				create = true;
-				publish = true;
-				retract = true;
-				delete = true;
-				get_nodes = true;
-				configure = true;
-				get_configuration = true;
-
-				subscribe = true;
-				unsubscribe = true;
-				get_subscription = true;
-				get_subscriptions = true;
-				get_items = true;
-
-
-				subscribe_other = true;
-				unsubscribe_other = true;
-				get_subscription_other = true;
-				get_subscriptions_other = true;
-
-				be_subscribed = true;
-				be_unsubscribed = true;
-
-				set_affiliation = true;
-			};
-		};
-
 		autocreate_on_publish = autocreate_on_publish;
 		autocreate_on_subscribe = autocreate_on_subscribe;
 
--- a/util/pubsub.lua	Wed Aug 08 20:40:44 2018 +0100
+++ b/util/pubsub.lua	Wed Aug 08 20:48:02 2018 +0100
@@ -9,7 +9,83 @@
 	itemcheck = function () return true; end;
 	get_affiliation = function () end;
 	normalize_jid = function (jid) return jid; end;
-	capabilities = {};
+	capabilities = {
+		restricted = {
+			be_subscribed = false;
+			be_unsubscribed = true;
+		};
+		none = {
+			create = false;
+			publish = false;
+			retract = false;
+			get_nodes = true;
+
+			subscribe = true;
+			unsubscribe = true;
+			get_subscription = true;
+			get_subscriptions = true;
+			get_items = true;
+
+			subscribe_other = false;
+			unsubscribe_other = false;
+			get_subscription_other = false;
+			get_subscriptions_other = false;
+
+			be_subscribed = true;
+			be_unsubscribed = true;
+
+			set_affiliation = false;
+		};
+		publisher = {
+			create = false;
+			publish = true;
+			retract = true;
+			get_nodes = true;
+			get_configuration = true;
+
+			subscribe = true;
+			unsubscribe = true;
+			get_subscription = true;
+			get_subscriptions = true;
+			get_items = true;
+
+			subscribe_other = false;
+			unsubscribe_other = false;
+			get_subscription_other = false;
+			get_subscriptions_other = false;
+
+			be_subscribed = true;
+			be_unsubscribed = true;
+
+			set_affiliation = false;
+		};
+		owner = {
+			create = true;
+			publish = true;
+			retract = true;
+			delete = true;
+			get_nodes = true;
+			configure = true;
+			get_configuration = true;
+
+			subscribe = true;
+			unsubscribe = true;
+			get_subscription = true;
+			get_subscriptions = true;
+			get_items = true;
+
+
+			subscribe_other = true;
+			unsubscribe_other = true;
+			get_subscription_other = true;
+			get_subscriptions_other = true;
+
+			be_subscribed = true;
+			be_unsubscribed = true;
+
+			set_affiliation = true;
+		};
+	};
 };
 local default_config_mt = { __index = default_config };