Changeset

1150:296820f18ba6

mod_mam: Add support for XEP-0334: Message Processing Hints
author Kim Alvefur <zash@zash.se>
date Sun, 11 Aug 2013 23:23:58 +0200
parents 1149:d055c44a7f61
children 1151:28d4b58bcc3b
files mod_mam/mod_mam.lua
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_mam/mod_mam.lua	Sun Aug 11 23:19:35 2013 +0200
+++ b/mod_mam/mod_mam.lua	Sun Aug 11 23:23:58 2013 +0200
@@ -180,11 +180,16 @@
 	local orig_to = stanza.attr.to or orig_from;
 	-- Stanza without 'to' are treated as if it was to their own bare jid
 
-	-- Don't store messages of these types
+	-- We don't store messages of these types
 	if orig_type == "error"
 	or orig_type == "headline"
 	or orig_type == "groupchat"
-	or not stanza:get_child("body") then
+	-- or that don't have a <body/>
+	or not stanza:get_child("body")
+	-- or if hints suggest we shouldn't
+	or stanza:get_child("no-permanent-store", "urn:xmpp:hints")
+	or stanza:get_child("no-store", "urn:xmpp:hints") then
+		module:log("debug", "Not archiving stanza: %s (content)", stanza:top_tag());
 		return;
 	end
 
@@ -203,7 +208,7 @@
 			stanza:tag("archived", { xmlns = xmlns_mam, by = store_user.."@"..host, id = id }):up();
 		end
 	else
-		module:log("debug", "Not archiving stanza: %s", stanza:top_tag());
+		module:log("debug", "Not archiving stanza: %s (prefs)", stanza:top_tag());
 	end
 end