Mercurial > prosody-hg
comparison plugins/mod_pubsub/pubsub.lib.lua @ 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 | eae0272b87e3 |
| children | eea166afad9b |
comparison
equal
deleted
inserted
replaced
| 13550:eae0272b87e3 | 13551:e17ff906d71b |
|---|---|
| 200 var = "FORM_TYPE"; | 200 var = "FORM_TYPE"; |
| 201 value = "http://jabber.org/protocol/pubsub#meta-data"; | 201 value = "http://jabber.org/protocol/pubsub#meta-data"; |
| 202 }; | 202 }; |
| 203 { | 203 { |
| 204 type = "text-single"; | 204 type = "text-single"; |
| 205 name = "pubsub#title"; | 205 name = "title"; |
| 206 var = "pubsub#title"; | |
| 206 }; | 207 }; |
| 207 { | 208 { |
| 208 type = "text-single"; | 209 type = "text-single"; |
| 209 name = "pubsub#description"; | 210 name = "description"; |
| 211 var = "pubsub#description"; | |
| 210 }; | 212 }; |
| 211 { | 213 { |
| 212 type = "text-single"; | 214 type = "text-single"; |
| 213 name = "pubsub#type"; | 215 name = "payload_type"; |
| 216 var = "pubsub#type"; | |
| 214 }; | 217 }; |
| 215 { | 218 { |
| 216 type = "text-single"; | 219 type = "text-single"; |
| 217 name = "pubsub#access_model"; | 220 name = "access_model"; |
| 221 var = "pubsub#access_model"; | |
| 218 }; | 222 }; |
| 219 { | 223 { |
| 220 type = "text-single"; | 224 type = "text-single"; |
| 221 name = "pubsub#publish_model"; | 225 name = "publish_model"; |
| 226 var = "pubsub#publish_model"; | |
| 222 }; | 227 }; |
| 223 }; | 228 }; |
| 224 _M.node_metadata_form = node_metadata_form; | 229 _M.node_metadata_form = node_metadata_form; |
| 225 | 230 |
| 226 local service_method_feature_map = { | 231 local service_method_feature_map = { |
| 295 event.origin.send(pubsub_error_reply(stanza, meta)); | 300 event.origin.send(pubsub_error_reply(stanza, meta)); |
| 296 return true; | 301 return true; |
| 297 end | 302 end |
| 298 event.exists = true; | 303 event.exists = true; |
| 299 reply:tag("identity", { category = "pubsub", type = "leaf" }):up(); | 304 reply:tag("identity", { category = "pubsub", type = "leaf" }):up(); |
| 300 reply:add_child(node_metadata_form:form({ | 305 reply:add_child(node_metadata_form:form(meta, "result")); |
| 301 ["pubsub#title"] = meta.title; | |
| 302 ["pubsub#description"] = meta.description; | |
| 303 ["pubsub#type"] = meta.payload_type; | |
| 304 ["pubsub#access_model"] = meta.access_model; | |
| 305 ["pubsub#publish_model"] = meta.publish_model; | |
| 306 }, "result")); | |
| 307 end | 306 end |
| 308 | 307 |
| 309 function _M.handle_disco_items_node(event, service) | 308 function _M.handle_disco_items_node(event, service) |
| 310 local stanza, reply, node = event.stanza, event.reply, event.node; | 309 local stanza, reply, node = event.stanza, event.reply, event.node; |
| 311 local ok, ret = service:get_items(node, stanza.attr.from); | 310 local ok, ret = service:get_items(node, stanza.attr.from); |
