aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2016-12-19 08:44:56 +0100
committerKim Alvefur <zash@zash.se>2016-12-19 08:44:56 +0100
commitd15ec87e01e22633da78db6113d70ac3da2b0e3f (patch)
treeb41ebbbc8d3050e0f6c2a07b6c9bdcc61d8942b8 /plugins
parentf2b74c28b0e0a6399c0487d93a39e42c849f17fa (diff)
downloadprosody-d15ec87e01e22633da78db6113d70ac3da2b0e3f.tar.gz
prosody-d15ec87e01e22633da78db6113d70ac3da2b0e3f.zip
mod_mam: Allow a set of namespaces to be stripped from stored stanzas, default to chat states (fixes #763)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_mam/mod_mam.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua
index 9d7aabde..898b81c8 100644
--- a/plugins/mod_mam/mod_mam.lua
+++ b/plugins/mod_mam/mod_mam.lua
@@ -32,6 +32,7 @@ local global_default_policy = module:get_option("default_archive_policy", true);
if global_default_policy ~= "roster" then
global_default_policy = module:get_option_boolean("default_archive_policy", global_default_policy);
end
+local strip_tags = module:get_option_set("dont_archive_namespaces", { "http://jabber.org/protocol/chatstates" });
local archive_store = "archive2";
local archive = assert(module:open_store(archive_store, "archive"));
@@ -265,6 +266,20 @@ local function message_handler(event, c2s)
end
end
+ if not strip_tags:empty() then
+ stanza = st.clone(stanza);
+ stanza:maptags(function (tag)
+ if strip_tags:contains(tag.attr.xmlns) then
+ return nil;
+ else
+ return tag;
+ end
+ end);
+ if #stanza.tags == 0 then
+ return;
+ end
+ end
+
-- Check with the users preferences
if shall_store(store_user, with) then
log("debug", "Archiving stanza: %s", stanza:top_tag());