# HG changeset patch # User Kim Alvefur # Date 1731028510 -3600 # Node ID e17ff906d71b7c4db320f1ee8f46b669409754ee # Parent eae0272b87e3e3203ff71771e40f9adb3e996f42 mod_pubsub: Pass metadata directly into form Reduces duplication and need to edit in two places when adding another metadata field. diff -r eae0272b87e3 -r e17ff906d71b plugins/mod_pubsub/pubsub.lib.lua --- 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)