mod_http_xep227: Add support for import via APIs rather than direct store manipulation
In particular this transitions PEP nodes and data to be imported via mod_pep's
APIs, fixing issues with importing at runtime while PEP data may already be
live in RAM.
Next obvious candidate for this approach is rosters, so clients get immediate
roster pushes and other special handling (such as emitting subscribes to reach
the desired subscription state).
-- Run JIDs through stringprep processing on behalf of clients
-- http://xmpp.org/extensions/inbox/jidprep.html
local jid_prep = require "util.jid".prep;
local st = require "util.stanza";
local xmlns_prep = "urn:xmpp:jidprep:0";
module:add_feature(xmlns_prep);
function prep_jid(event)
local stanza = event.stanza;
local jid = jid_prep(stanza:get_child_text("jid", xmlns_prep));
if not jid then
return event.origin.send(st.error_reply(stanza, "modify", "jid-malformed"));
end
return event.origin.send(st.reply(stanza):tag("jid", { xmlns = xmlns_prep }):text(jid));
end
module:hook("iq/host/"..xmlns_prep..":jid", prep_jid);
module:depends("http");
module:provides("http", {
route = {
["GET /*"] = function (event, jid)
return jid_prep(jid) or 400;
end;
}
});