Changeset

1187:d677d1807bb0

mod_mam: Stamp outgoing messages with <archived> as well, but remove it after they should have passed through mod_carbons
author Kim Alvefur <zash@zash.se>
date Thu, 05 Sep 2013 15:48:37 +0200
parents 1186:a172e7389cf6
children 1188:5eaecb7f680d
files mod_mam/mod_mam.lua
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_mam/mod_mam.lua	Thu Sep 05 15:24:09 2013 +0200
+++ b/mod_mam/mod_mam.lua	Thu Sep 05 15:48:37 2013 +0200
@@ -202,7 +202,7 @@
 
 		-- And stash it
 		local ok, id = archive:append(store_user, time_now(), with, stanza);
-		if ok and not c2s then
+		if ok then
 			stanza:tag("archived", { xmlns = xmlns_mam, by = store_user.."@"..host, id = id }):up();
 		end
 	else
@@ -221,5 +221,16 @@
 module:hook("message/bare", message_handler, 2);
 module:hook("message/full", message_handler, 2);
 
+local function post_carbons_handler(event)
+	event.stanza:maptags(function(tag)
+		if not ( tag.attr.xmlns == xmlns_mam and tag.name == "archived" ) then
+			return tag;
+		end
+	end);
+end
+
+module:hook("pre-message/bare", post_carbons_handler, 0.9);
+module:hook("pre-message/full", post_carbons_handler, 0.9);
+
 module:add_feature(xmlns_mam);