diff options
author | Kim Alvefur <zash@zash.se> | 2020-04-21 01:01:25 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-04-21 01:01:25 +0200 |
commit | baef0f02e863f093af83003598949c94e9a82218 (patch) | |
tree | 135090f074a805ce92ea2fac5b45812a09f20baa /plugins/mod_mam/mod_mam.lua | |
parent | 5c12379ed9273e2be201476763ef51af96b43fff (diff) | |
download | prosody-baef0f02e863f093af83003598949c94e9a82218.tar.gz prosody-baef0f02e863f093af83003598949c94e9a82218.zip |
mod_mam: Rework hints handling
Improved readability and early returns definite yes/no answer.
Diffstat (limited to 'plugins/mod_mam/mod_mam.lua')
-rw-r--r-- | plugins/mod_mam/mod_mam.lua | 13 |
1 files changed, 6 insertions, 7 deletions
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 |