# HG changeset patch # User Kim Alvefur # Date 1587423685 -7200 # Node ID b2ede421adeb82b8d557171220e408985f525ee6 # Parent c5a3576a53358b72adb0a385aefb21730fc64e4d mod_mam: Rework hints handling Improved readability and early returns definite yes/no answer. diff -r c5a3576a5335 -r b2ede421adeb plugins/mod_mam/mod_mam.lua --- 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