# HG changeset patch # User Kim Alvefur # Date 1482133496 -3600 # Node ID 93a068ef4b2cea3d4fdd8078d000a1fe0ba09d56 # Parent efe5232793aa8e47a9d00bade0a7763f85f01a93 mod_mam: Allow a set of namespaces to be stripped from stored stanzas, default to chat states (fixes #763) diff -r efe5232793aa -r 93a068ef4b2c plugins/mod_mam/mod_mam.lua --- a/plugins/mod_mam/mod_mam.lua Tue Nov 22 18:19:55 2016 +0100 +++ b/plugins/mod_mam/mod_mam.lua Mon Dec 19 08:44:56 2016 +0100 @@ -32,6 +32,7 @@ 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 @@ 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());