Software /
code /
prosody
Comparison
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 |
comparison
equal
deleted
inserted
replaced
12456:64722dcb0b8c | 12457:8b7895266e99 |
---|---|
277 return true; | 277 return true; |
278 end; | 278 end; |
279 }; | 279 }; |
280 | 280 |
281 -- PEP node configuration/etc. (not items) | 281 -- PEP node configuration/etc. (not items) |
282 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | |
282 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; | 283 local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; |
283 local lib_pubsub = module:require "pubsub"; | 284 local lib_pubsub = module:require "pubsub"; |
284 handlers.pep = { | 285 handlers.pep = { |
285 get = function (self, user) | 286 get = function (self, user) |
286 local xml = self:_get_user_xml(user, self.host); | 287 local xml = self:_get_user_xml(user, self.host); |
298 }; | 299 }; |
299 ]] | 300 ]] |
300 }; | 301 }; |
301 local owner_el = user_el:get_child("pubsub", xmlns_pubsub_owner); | 302 local owner_el = user_el:get_child("pubsub", xmlns_pubsub_owner); |
302 if not owner_el then | 303 if not owner_el then |
303 return nil; | 304 local pubsub_el = user_el:get_child("pubsub", xmlns_pubsub); |
305 if not pubsub_el then | |
306 return nil; | |
307 end | |
308 for node_el in pubsub_el:childtags("items") do | |
309 nodes[node_el.attr.node] = { | |
310 node = node_el.attr.node; | |
311 } | |
312 end | |
313 return nodes; | |
304 end | 314 end |
305 for node_el in owner_el:childtags() do | 315 for node_el in owner_el:childtags() do |
306 local node_name = node_el.attr.node; | 316 local node_name = node_el.attr.node; |
307 local node = nodes[node_name]; | 317 local node = nodes[node_name]; |
308 if not node then | 318 if not node then |
394 return self:_set_user_xml(user, self.host, xml); | 404 return self:_set_user_xml(user, self.host, xml); |
395 end; | 405 end; |
396 }; | 406 }; |
397 | 407 |
398 -- PEP items | 408 -- PEP items |
399 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | |
400 handlers.pep_ = { | 409 handlers.pep_ = { |
401 _stores = function (self, xml) --luacheck: ignore 212/self | 410 _stores = function (self, xml) --luacheck: ignore 212/self |
402 local store_names = set.new(); | 411 local store_names = set.new(); |
403 | 412 |
404 local user_el = xml and getUserElement(xml); | 413 local user_el = xml and getUserElement(xml); |