diff options
author | Kim Alvefur <zash@zash.se> | 2020-04-21 00:56:56 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-04-21 00:56:56 +0200 |
commit | 5c12379ed9273e2be201476763ef51af96b43fff (patch) | |
tree | 7c21927f339cebc2b5e1930d4acfb0bb55155a78 /plugins/mod_mam/mod_mam.lua | |
parent | 9549657e06f1d565bdc11808eb10da8707b91c40 (diff) | |
download | prosody-5c12379ed9273e2be201476763ef51af96b43fff.tar.gz prosody-5c12379ed9273e2be201476763ef51af96b43fff.zip |
mod_mam: Invert check for type
This is based on code in mod_csi_simple and aiming towards being more
flexible and maintainable than a couple of tests for when not to store.
Diffstat (limited to 'plugins/mod_mam/mod_mam.lua')
-rw-r--r-- | plugins/mod_mam/mod_mam.lua | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index 9c00cc99..028c3b8f 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -264,11 +264,8 @@ local function strip_stanza_id(stanza, user) end local function should_store(stanza) --> boolean, reason: string - local orig_type = stanza.attr.type or "normal"; - -- We store chat messages or normal messages that have a body - if not(orig_type == "chat" or (orig_type == "normal" and stanza:get_child("body")) ) then - return false, "type"; - end + 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 @@ -277,6 +274,17 @@ local function should_store(stanza) --> boolean, reason: string return false, "hint"; end end + if st_type == "headline" then + -- Headline messages are ephemeral by definition + return false, "headline"; + end + if st_type == "groupchat" and st_to_full then + -- MUC messages always go to the full JID, usually archived by the MUC + return false, "groupchat"; + end + if stanza:get_child("body") then + return true, "body"; + end return true, "default"; end |