comparison mod_http_xep227/mod_http_xep227.lua @ 4869:c3bf568e3977

mod_http_xep227: Initialize XEP-0227 XML mod_storage_xep0227 only writes if there is XML already for a user (it uses the presence of an existing <user> element as an indicator that an account exists, although technically this is not something Prosody itself does, so it's a little weird).
author Matthew Wild <mwild1@gmail.com>
date Sat, 15 Jan 2022 14:25:27 +0000
parents 57311c545013
children d8a0a8dcdc0d
comparison
equal deleted inserted replaced
4868:57311c545013 4869:c3bf568e3977
1 local it = require "util.iterators"; 1 local it = require "util.iterators";
2 local http = require "util.http"; 2 local http = require "util.http";
3 local sm = require "core.storagemanager"; 3 local sm = require "core.storagemanager";
4 local st = require "util.stanza";
4 local xml = require "util.xml"; 5 local xml = require "util.xml";
5 6
6 local tokens = module:depends("tokenauth"); 7 local tokens = module:depends("tokenauth");
7 module:depends("storage_xep0227"); 8 module:depends("storage_xep0227");
8 9
18 [archive_store_name] = "archive"; 19 [archive_store_name] = "archive";
19 pep_data = "archive"; 20 pep_data = "archive";
20 }; 21 };
21 22
22 local function new_user_xml(username, host) 23 local function new_user_xml(username, host)
23 local user_xml; 24 local user_xml = st.stanza("server-data", {xmlns='urn:xmpp:pie:0'})
25 :tag("host", { jid = host })
26 :tag("user", { name = username }):reset();
24 27
25 return { 28 return {
26 set_user_xml = function (_, store_username, store_host, new_xml) 29 set_user_xml = function (_, store_username, store_host, new_xml)
27 if username ~= store_username or store_host ~= host then 30 if username ~= store_username or store_host ~= host then
28 return nil; 31 return nil;