From 0613c5b47f429e34ca3cbe4eec671e2f281321a8 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Tue, 21 Apr 2020 01:01:25 +0200 Subject: mod_mam: Rework hints handling Improved readability and early returns definite yes/no answer. --- plugins/mod_mam/mod_mam.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'plugins/mod_mam/mod_mam.lua') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 028c3b8f..57f399ae 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -267,13 +267,6 @@ local function should_store(stanza) --> boolean, reason: string 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 @@ local function should_store(stanza) --> boolean, reason: string -- 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 -- cgit v1.2.3