Comparison

plugins/mod_pubsub/pubsub.lib.lua @ 13550:eae0272b87e3

mod_pubsub: Use new metadata method No longer bypasses access control to retrieve this config subset, which is also explicitly named in the service config now.
author Kim Alvefur <zash@zash.se>
date Fri, 08 Nov 2024 02:12:45 +0100
parent 13535:88cab98aa28c
child 13551:e17ff906d71b
comparison
equal deleted inserted replaced
13549:3b357ab6b6eb 13550:eae0272b87e3
288 return supported_features; 288 return supported_features;
289 end 289 end
290 290
291 function _M.handle_disco_info_node(event, service) 291 function _M.handle_disco_info_node(event, service)
292 local stanza, reply, node = event.stanza, event.reply, event.node; 292 local stanza, reply, node = event.stanza, event.reply, event.node;
293 local ok, ret = service:get_nodes(stanza.attr.from); 293 local ok, meta = service:get_node_metadata(node, stanza.attr.from);
294 if not ok then 294 if not ok then
295 event.origin.send(pubsub_error_reply(stanza, ret)); 295 event.origin.send(pubsub_error_reply(stanza, meta));
296 return true;
297 end
298 local node_obj = ret[node];
299 if not node_obj then
300 event.origin.send(pubsub_error_reply(stanza, "item-not-found"));
301 return true; 296 return true;
302 end 297 end
303 event.exists = true; 298 event.exists = true;
304 reply:tag("identity", { category = "pubsub", type = "leaf" }):up(); 299 reply:tag("identity", { category = "pubsub", type = "leaf" }):up();
305 if node_obj.config then 300 reply:add_child(node_metadata_form:form({
306 reply:add_child(node_metadata_form:form({ 301 ["pubsub#title"] = meta.title;
307 ["pubsub#title"] = node_obj.config.title; 302 ["pubsub#description"] = meta.description;
308 ["pubsub#description"] = node_obj.config.description; 303 ["pubsub#type"] = meta.payload_type;
309 ["pubsub#type"] = node_obj.config.payload_type; 304 ["pubsub#access_model"] = meta.access_model;
310 ["pubsub#access_model"] = node_obj.config.access_model; 305 ["pubsub#publish_model"] = meta.publish_model;
311 ["pubsub#publish_model"] = node_obj.config.publish_model; 306 }, "result"));
312 }, "result"));
313 end
314 end 307 end
315 308
316 function _M.handle_disco_items_node(event, service) 309 function _M.handle_disco_items_node(event, service)
317 local stanza, reply, node = event.stanza, event.reply, event.node; 310 local stanza, reply, node = event.stanza, event.reply, event.node;
318 local ok, ret = service:get_items(node, stanza.attr.from); 311 local ok, ret = service:get_items(node, stanza.attr.from);