# HG changeset patch # User Kim Alvefur # Date 1376162232 -7200 # Node ID fabdaa0d99e35694e5454995e6e8c3141b7e97ec # Parent 1091be1c3abaaca3c85145b5cd655be31e63e846 mod_mam_muc: Stap archived messages diff -r 1091be1c3aba -r fabdaa0d99e3 mod_mam_muc/mod_mam_muc.lua --- a/mod_mam_muc/mod_mam_muc.lua Sat Aug 10 21:15:25 2013 +0200 +++ b/mod_mam_muc/mod_mam_muc.lua Sat Aug 10 21:17:12 2013 +0200 @@ -23,6 +23,8 @@ local timestamp, timestamp_parse = require "util.datetime".datetime, require "util.datetime".parse; local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", 50); +local advertise_archive = module:get_option_boolean("muc_log_advertise", true); + local archive = module:open_store("archive2", "archive"); local rooms = hosts[module.host].modules.muc.rooms; @@ -133,8 +135,11 @@ stanza.attr.from = nick; -- And stash it - archive:append(room, time_now(), "", stanza); + local ok, id = archive:append(room, time_now(), "", stanza); stanza.attr.from = orig_from; + if ok and advertise_archive then + stanza:tag("archived", { xmlns = xmlns_mam, by = jid_bare(orig_to), id = id }):up(); + end end module:hook("message/bare", message_handler, 2);