aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-04-21 01:01:25 +0200
committerKim Alvefur <zash@zash.se>2020-04-21 01:01:25 +0200
commit0613c5b47f429e34ca3cbe4eec671e2f281321a8 (patch)
tree135090f074a805ce92ea2fac5b45812a09f20baa /plugins
parente5d6376c58d026003fbcee2dff60a7b244debbdb (diff)
downloadprosody-0613c5b47f429e34ca3cbe4eec671e2f281321a8.tar.gz
prosody-0613c5b47f429e34ca3cbe4eec671e2f281321a8.zip
mod_mam: Rework hints handling
Improved readability and early returns definite yes/no answer.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_mam/mod_mam.lua13
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