aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_mam
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-02-20 01:46:54 +0100
committerKim Alvefur <zash@zash.se>2017-02-20 01:46:54 +0100
commitb4b6f7ef293ce05cd9c69d1a2e30e678e8c6d9eb (patch)
treebe7c0181ec8542e0a1056c284cc24ca66e36b9e4 /plugins/mod_mam
parent20ff11cfc9b824ae15e5315248c6ce368c0d0d3f (diff)
parent2a767fee411984dbf1bbc8d845404d73db0234d7 (diff)
downloadprosody-b4b6f7ef293ce05cd9c69d1a2e30e678e8c6d9eb.tar.gz
prosody-b4b6f7ef293ce05cd9c69d1a2e30e678e8c6d9eb.zip
Merge 0.10->trunk
Diffstat (limited to 'plugins/mod_mam')
-rw-r--r--plugins/mod_mam/mamprefsxml.lib.lua2
-rw-r--r--plugins/mod_mam/mod_mam.lua24
2 files changed, 19 insertions, 7 deletions
diff --git a/plugins/mod_mam/mamprefsxml.lib.lua b/plugins/mod_mam/mamprefsxml.lib.lua
index 0598bbcd..8eee78d8 100644
--- a/plugins/mod_mam/mamprefsxml.lib.lua
+++ b/plugins/mod_mam/mamprefsxml.lib.lua
@@ -10,7 +10,7 @@
--
local st = require"util.stanza";
-local xmlns_mam = "urn:xmpp:mam:1";
+local xmlns_mam = "urn:xmpp:mam:2";
local default_attrs = {
always = true, [true] = "always",
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua
index 81b0690c..6e6d6383 100644
--- a/plugins/mod_mam/mod_mam.lua
+++ b/plugins/mod_mam/mod_mam.lua
@@ -9,7 +9,7 @@
-- XEP-0313: Message Archive Management for Prosody
--
-local xmlns_mam = "urn:xmpp:mam:1";
+local xmlns_mam = "urn:xmpp:mam:2";
local xmlns_delay = "urn:xmpp:delay";
local xmlns_forward = "urn:xmpp:forward:0";
local xmlns_st_id = "urn:xmpp:sid:0";
@@ -89,7 +89,7 @@ local query_form = dataform {
-- Serve form
module:hook("iq-get/self/"..xmlns_mam..":query", function(event)
local origin, stanza = event.origin, event.stanza;
- origin.send(st.reply(stanza):add_child(query_form:form()));
+ origin.send(st.reply(stanza):query(xmlns_mam):add_child(query_form:form()));
return true;
end);
@@ -134,7 +134,6 @@ module:hook("iq-set/self/"..xmlns_mam..":query", function(event)
local before, after = qset and qset.before, qset and qset.after;
if type(before) ~= "string" then before = nil; end
-
-- Load all the data!
local data, err = archive:find(origin.username, {
start = qstart; ["end"] = qend; -- Time range
@@ -292,8 +291,9 @@ local function message_handler(event, c2s)
log("debug", "Archiving stanza: %s", stanza:top_tag());
-- And stash it
- local ok, id = archive:append(store_user, nil, stanza, time_now(), with);
+ local ok = archive:append(store_user, nil, stanza, time_now(), with);
if ok then
+ local id = ok;
stanza:tag("stanza-id", { xmlns = xmlns_st_id, by = store_user.."@"..host, id = id }):up();
if cleanup then cleanup[store_user] = true; end
module:fire_event("archive-message-added", { origin = origin, stanza = stanza, for_user = store_user, id = id });
@@ -307,6 +307,18 @@ local function c2s_message_handler(event)
return message_handler(event, true);
end
+local function strip_stanza_id(event)
+ local strip_by = jid_bare(event.origin.full_jid);
+ event.stanza:maptags(function(tag)
+ if not ( tag.attr.xmlns == xmlns_st_id and tag.attr.by == strip_by ) then
+ return tag;
+ end
+ end);
+end
+
+module:hook("pre-message/bare", strip_stanza_id, -1);
+module:hook("pre-message/full", strip_stanza_id, -1);
+
local cleanup_after = module:get_option_string("archive_expires_after", "1w");
local cleanup_interval = module:get_option_number("archive_cleanup_interval", 4 * 60 * 60);
if cleanup_after ~= "never" then
@@ -334,7 +346,7 @@ if cleanup_after ~= "never" then
-- Iterating over users is not supported by all authentication modules
-- Catch and ignore error if not supported
pcall(function ()
- -- If this works, then we schedule cleanup for all known known
+ -- If this works, then we schedule cleanup for all known users on startup
for user in um.users(module.host) do
cleanup[user] = true;
end
@@ -360,7 +372,7 @@ end
-- Stanzas sent by local clients
module:hook("pre-message/bare", c2s_message_handler, 0);
module:hook("pre-message/full", c2s_message_handler, 0);
--- Stanszas to local clients
+-- Stanzas to local clients
module:hook("message/bare", message_handler, 0);
module:hook("message/full", message_handler, 0);