Changeset

10737:b2ede421adeb

mod_mam: Rework hints handling Improved readability and early returns definite yes/no answer.
author Kim Alvefur <zash@zash.se>
date Tue, 21 Apr 2020 01:01:25 +0200
parents 10736:c5a3576a5335
children 10738:19ffb2ebf114
files plugins/mod_mam/mod_mam.lua
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_mam/mod_mam.lua	Tue Apr 21 00:56:56 2020 +0200
+++ b/plugins/mod_mam/mod_mam.lua	Tue Apr 21 01:01:25 2020 +0200
@@ -267,13 +267,6 @@
 	local st_type = stanza.attr.type or "normal";
 	local st_to_full = (stanza.attr.to or ""):find("/");
 
-	-- or if hints suggest we shouldn't
-	if not stanza:get_child("store", "urn:xmpp:hints") then -- No hint telling us we should store
-		if stanza:get_child("no-permanent-store", "urn:xmpp:hints")
-			or stanza:get_child("no-store", "urn:xmpp:hints") then -- Hint telling us we should NOT store
-			return false, "hint";
-		end
-	end
 	if st_type == "headline" then
 		-- Headline messages are ephemeral by definition
 		return false, "headline";
@@ -282,6 +275,12 @@
 		-- MUC messages always go to the full JID, usually archived by the MUC
 		return false, "groupchat";
 	end
+	if stanza:get_child("no-permanent-store", "urn:xmpp:hints") then
+		return false, "hint";
+	end
+	if stanza:get_child("store", "urn:xmpp:hints") then
+		return true, "hint";
+	end
 	if stanza:get_child("body") then
 		return true, "body";
 	end