Comparison

plugins/mod_pubsub/pubsub.lib.lua @ 12960:31b22cc221b5

mod_pubsub, mod_pep: Support per-node configurable inclusion of publisher This matches ejabberd's behaviour, using the 'pubsub#itemreply' config option. Although the current definition of this option in the specification is not as clear as it could be, I think matching what existing deployments do is the best option to resolve the ambiguity and reduce fragmentation. We should update the spec to be clearer about how to use and interpret this option. The 'expose_publisher' option for mod_pubsub is now an override (always expose or never expose). If unset, it will use the per-node config (which defaults to not exposing). Thanks to Link Mauve, edhelas and goffi for sparking this feature.
author Matthew Wild <mwild1@gmail.com>
date Wed, 22 Mar 2023 11:39:19 +0000
parent 12636:e8934ce6ea0f
child 12961:1cbfa843f8c3
comparison
equal deleted inserted replaced
12959:e331210beeb2 12960:31b22cc221b5
162 label = "Whether to notify subscribers when items are removed from the node"; 162 label = "Whether to notify subscribers when items are removed from the node";
163 name = "notify_retract"; 163 name = "notify_retract";
164 var = "pubsub#notify_retract"; 164 var = "pubsub#notify_retract";
165 value = true; 165 value = true;
166 }; 166 };
167 {
168 type = "list-single";
169 label = "Specify whose JID to include as the publisher of items";
170 name = "pubsub#itemreply";
171 var = "itemreply";
172 options = {
173 { label = "Include the node owner's JID", value = "owner" };
174 { label = "Include the item publisher's JID", value = "publisher" };
175 { label = "Don't include any JID with items", value = "none", default = true };
176 };
177 };
167 }; 178 };
168 _M.node_config_form = node_config_form; 179 _M.node_config_form = node_config_form;
169 180
170 local subscribe_options_form = dataform { 181 local subscribe_options_form = dataform {
171 { 182 {
345 356
346 if not node then 357 if not node then
347 origin.send(pubsub_error_reply(stanza, "nodeid-required")); 358 origin.send(pubsub_error_reply(stanza, "nodeid-required"));
348 return true; 359 return true;
349 end 360 end
361
362 local node_obj = service.nodes[node];
363 if not node_obj then
364 origin.send(pubsub_error_reply(stanza, "item-not-found"));
365 return true;
366 end
367
350 local resultspec; -- TODO rsm.get() 368 local resultspec; -- TODO rsm.get()
351 if items.attr.max_items then 369 if items.attr.max_items then
352 resultspec = { max = tonumber(items.attr.max_items) }; 370 resultspec = { max = tonumber(items.attr.max_items) };
353 end 371 end
354 local ok, results = service:get_items(node, stanza.attr.from, requested_items, resultspec); 372 local ok, results = service:get_items(node, stanza.attr.from, requested_items, resultspec);
356 origin.send(pubsub_error_reply(stanza, results)); 374 origin.send(pubsub_error_reply(stanza, results));
357 return true; 375 return true;
358 end 376 end
359 377
360 local expose_publisher = service.config.expose_publisher; 378 local expose_publisher = service.config.expose_publisher;
379 if expose_publisher == nil and node_obj.config.itemreply == "publisher" then
380 expose_publisher = true;
381 end
361 382
362 local data = st.stanza("items", { node = node }); 383 local data = st.stanza("items", { node = node });
363 local iter, v, i = ipairs(results); 384 local iter, v, i = ipairs(results);
364 if not requested_items then 385 if not requested_items then
365 -- XXX Hack to preserve order of explicitly requested items. 386 -- XXX Hack to preserve order of explicitly requested items.