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 | e5d6376c58d026003fbcee2dff60a7b244debbdb (patch) | |
tree | 7c21927f339cebc2b5e1930d4acfb0bb55155a78 /plugins/mod_mam/mod_mam.lua | |
parent | 962d36d401a1a55346a92fe3b30c6b215583fada (diff) | |
download | prosody-e5d6376c58d026003fbcee2dff60a7b244debbdb.tar.gz prosody-e5d6376c58d026003fbcee2dff60a7b244debbdb.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 |