Changeset

13551:e17ff906d71b

mod_pubsub: Pass metadata directly into form Reduces duplication and need to edit in two places when adding another metadata field.
author Kim Alvefur <zash@zash.se>
date Fri, 08 Nov 2024 02:15:10 +0100
parents 13550:eae0272b87e3
children 13552:f0b2c026e542
files plugins/mod_pubsub/pubsub.lib.lua
diffstat 1 files changed, 11 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_pubsub/pubsub.lib.lua	Fri Nov 08 02:12:45 2024 +0100
+++ b/plugins/mod_pubsub/pubsub.lib.lua	Fri Nov 08 02:15:10 2024 +0100
@@ -202,23 +202,28 @@
 	};
 	{
 		type = "text-single";
-		name = "pubsub#title";
+		name = "title";
+		var = "pubsub#title";
 	};
 	{
 		type = "text-single";
-		name = "pubsub#description";
+		name = "description";
+		var = "pubsub#description";
 	};
 	{
 		type = "text-single";
-		name = "pubsub#type";
+		name = "payload_type";
+		var = "pubsub#type";
 	};
 	{
 		type = "text-single";
-		name = "pubsub#access_model";
+		name = "access_model";
+		var = "pubsub#access_model";
 	};
 	{
 		type = "text-single";
-		name = "pubsub#publish_model";
+		name = "publish_model";
+		var = "pubsub#publish_model";
 	};
 };
 _M.node_metadata_form = node_metadata_form;
@@ -297,13 +302,7 @@
 	end
 	event.exists = true;
 	reply:tag("identity", { category = "pubsub", type = "leaf" }):up();
-	reply:add_child(node_metadata_form:form({
-		["pubsub#title"] = meta.title;
-		["pubsub#description"] = meta.description;
-		["pubsub#type"] = meta.payload_type;
-		["pubsub#access_model"] = meta.access_model;
-		["pubsub#publish_model"] = meta.publish_model;
-	}, "result"));
+	reply:add_child(node_metadata_form:form(meta, "result"));
 end
 
 function _M.handle_disco_items_node(event, service)