Diff

plugins/mod_storage_xep0227.lua @ 12457:8b7895266e99 0.12

mod_storage_xep0227: Support basic listing of PEP nodes in absence of pubsub#admin data Allows migrating PEP nodes with default settings
author Kim Alvefur <zash@zash.se>
date Thu, 31 Mar 2022 18:53:23 +0200
parent 12456:64722dcb0b8c
child 12458:10cc52e4b310
line wrap: on
line diff
--- a/plugins/mod_storage_xep0227.lua	Tue Mar 29 19:58:28 2022 +0200
+++ b/plugins/mod_storage_xep0227.lua	Thu Mar 31 18:53:23 2022 +0200
@@ -279,6 +279,7 @@
 };
 
 -- PEP node configuration/etc. (not items)
+local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner";
 local lib_pubsub = module:require "pubsub";
 handlers.pep = {
@@ -300,7 +301,16 @@
 		};
 		local owner_el = user_el:get_child("pubsub", xmlns_pubsub_owner);
 		if not owner_el then
-			return nil;
+			local pubsub_el = user_el:get_child("pubsub", xmlns_pubsub);
+			if not pubsub_el then
+				return nil;
+			end
+			for node_el in pubsub_el:childtags("items") do
+				nodes[node_el.attr.node] = {
+					node = node_el.attr.node;
+				}
+			end
+			return nodes;
 		end
 		for node_el in owner_el:childtags() do
 			local node_name = node_el.attr.node;
@@ -396,7 +406,6 @@
 };
 
 -- PEP items
-local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
 handlers.pep_ = {
 	_stores = function (self, xml) --luacheck: ignore 212/self
 		local store_names = set.new();