Comparison

plugins/mod_mam/mod_mam.lua @ 7902:92b70a921acb

mod_mam: Strip stanza-id tags after carbons
author Kim Alvefur <zash@zash.se>
date Sun, 19 Feb 2017 23:39:53 +0100
parent 7901:fc859aed9279
child 7903:036c771b842a
comparison
equal deleted inserted replaced
7901:fc859aed9279 7902:92b70a921acb
305 305
306 local function c2s_message_handler(event) 306 local function c2s_message_handler(event)
307 return message_handler(event, true); 307 return message_handler(event, true);
308 end 308 end
309 309
310
311 local function strip_stanza_id(event)
312 local strip_by = jid_bare(event.origin.full_jid);
313 event.stanza:maptags(function(tag)
314 if not ( tag.attr.xmlns == xmlns_st_id and tag.attr.by == strip_by ) then
315 return tag;
316 end
317 end);
318 end
319
320 module:hook("pre-message/bare", strip_stanza_id, -1);
321 module:hook("pre-message/full", strip_stanza_id, -1);
322
310 local cleanup_after = module:get_option_string("archive_expires_after", "1w"); 323 local cleanup_after = module:get_option_string("archive_expires_after", "1w");
311 local cleanup_interval = module:get_option_number("archive_cleanup_interval", 4 * 60 * 60); 324 local cleanup_interval = module:get_option_number("archive_cleanup_interval", 4 * 60 * 60);
312 if cleanup_after ~= "never" then 325 if cleanup_after ~= "never" then
313 local day = 86400; 326 local day = 86400;
314 local multipliers = { d = day, w = day * 7, m = 31 * day, y = 365.2425 * day }; 327 local multipliers = { d = day, w = day * 7, m = 31 * day, y = 365.2425 * day };