Changeset

1142:fabdaa0d99e3

mod_mam_muc: Stap archived messages
author Kim Alvefur <zash@zash.se>
date Sat, 10 Aug 2013 21:17:12 +0200
parents 1141:1091be1c3aba
children 1143:8098683b6d6f
files mod_mam_muc/mod_mam_muc.lua
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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);