Software /
code /
prosody
Comparison
plugins/mod_mam/mod_mam.lua @ 7849:93a068ef4b2c
mod_mam: Allow a set of namespaces to be stripped from stored stanzas, default to chat states (fixes #763)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 19 Dec 2016 08:44:56 +0100 |
parent | 7848:efe5232793aa |
child | 7850:10d91860172f |
comparison
equal
deleted
inserted
replaced
7848:efe5232793aa | 7849:93a068ef4b2c |
---|---|
30 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); | 30 local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); |
31 local global_default_policy = module:get_option("default_archive_policy", true); | 31 local global_default_policy = module:get_option("default_archive_policy", true); |
32 if global_default_policy ~= "roster" then | 32 if global_default_policy ~= "roster" then |
33 global_default_policy = module:get_option_boolean("default_archive_policy", global_default_policy); | 33 global_default_policy = module:get_option_boolean("default_archive_policy", global_default_policy); |
34 end | 34 end |
35 local strip_tags = module:get_option_set("dont_archive_namespaces", { "http://jabber.org/protocol/chatstates" }); | |
35 | 36 |
36 local archive_store = "archive2"; | 37 local archive_store = "archive2"; |
37 local archive = assert(module:open_store(archive_store, "archive")); | 38 local archive = assert(module:open_store(archive_store, "archive")); |
38 | 39 |
39 if archive.name == "null" or not archive.find then | 40 if archive.name == "null" or not archive.find then |
263 log("debug", "Not archiving stanza: %s (hint)", stanza:top_tag()); | 264 log("debug", "Not archiving stanza: %s (hint)", stanza:top_tag()); |
264 return; | 265 return; |
265 end | 266 end |
266 end | 267 end |
267 | 268 |
269 if not strip_tags:empty() then | |
270 stanza = st.clone(stanza); | |
271 stanza:maptags(function (tag) | |
272 if strip_tags:contains(tag.attr.xmlns) then | |
273 return nil; | |
274 else | |
275 return tag; | |
276 end | |
277 end); | |
278 if #stanza.tags == 0 then | |
279 return; | |
280 end | |
281 end | |
282 | |
268 -- Check with the users preferences | 283 -- Check with the users preferences |
269 if shall_store(store_user, with) then | 284 if shall_store(store_user, with) then |
270 log("debug", "Archiving stanza: %s", stanza:top_tag()); | 285 log("debug", "Archiving stanza: %s", stanza:top_tag()); |
271 | 286 |
272 -- And stash it | 287 -- And stash it |