Comparison

plugins/mod_storage_xep0227.lua @ 12459:c0bc8025acf4

Merge 0.12->trunk
author Kim Alvefur <zash@zash.se>
date Fri, 08 Apr 2022 15:17:11 +0200
parent 12458:10cc52e4b310
child 12460:f7e40f1a5f53
comparison
equal deleted inserted replaced
12455:e703a9d71360 12459:c0bc8025acf4
57 if user and user.name == "user" then 57 if user and user.name == "user" then
58 return user; 58 return user;
59 end 59 end
60 end 60 end
61 end 61 end
62 module:log("warn", "Unable to find user element"); 62 module:log("warn", "Unable to find user element in %s", xml and xml:top_tag() or "nothing");
63 end 63 end
64 local function createOuterXml(user, host) 64 local function createOuterXml(user, host)
65 return st.stanza("server-data", {xmlns='urn:xmpp:pie:0'}) 65 return st.stanza("server-data", {xmlns='urn:xmpp:pie:0'})
66 :tag("host", {jid=host}) 66 :tag("host", {jid=host})
67 :tag("user", {name = user}); 67 :tag("user", {name = user});
70 local function hex_to_base64(s) 70 local function hex_to_base64(s)
71 return base64.encode(hex.decode(s)); 71 return base64.encode(hex.decode(s));
72 end 72 end
73 73
74 local function base64_to_hex(s) 74 local function base64_to_hex(s)
75 return base64.encode(hex.decode(s)); 75 return hex.encode(base64.decode(s));
76 end 76 end
77 77
78 local handlers = {}; 78 local handlers = {};
79 79
80 -- In order to support custom account properties 80 -- In order to support custom account properties
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);