Comparison

mod_mam/mod_mam.lua @ 1790:4c2146f5bf39

mod_mam: Store chat messages and normal messages with a body
author Kim Alvefur <zash@zash.se>
date Wed, 26 Aug 2015 17:40:22 +0200
parent 1788:d2b82b90c413
child 1957:ca33cca2e028
comparison
equal deleted inserted replaced
1789:dbce8a7726ef 1790:4c2146f5bf39
221 local orig_type = stanza.attr.type or "normal"; 221 local orig_type = stanza.attr.type or "normal";
222 local orig_from = stanza.attr.from; 222 local orig_from = stanza.attr.from;
223 local orig_to = stanza.attr.to or orig_from; 223 local orig_to = stanza.attr.to or orig_from;
224 -- Stanza without 'to' are treated as if it was to their own bare jid 224 -- Stanza without 'to' are treated as if it was to their own bare jid
225 225
226 -- We don't store messages of these types 226 -- We store chat messages or normal messages that have a body
227 if orig_type == "error" 227 if not(orig_type == "chat" or orig_type == "normal" and stanza:get_child("body") ) then
228 or orig_type == "headline" 228 module:log("debug", "Not archiving stanza: %s (type)", stanza:top_tag());
229 or orig_type == "groupchat" 229 return;
230 -- or that don't have a <body/> 230 end
231 or not stanza:get_child("body")
232 -- or if hints suggest we shouldn't 231 -- or if hints suggest we shouldn't
233 or stanza:get_child("no-permanent-storage", "urn:xmpp:hints") -- The XEP needs to decide on "store" or "storage" 232 if stanza:get_child("no-permanent-storage", "urn:xmpp:hints") -- The XEP needs to decide on "store" or "storage"
234 or stanza:get_child("no-permanent-store", "urn:xmpp:hints") 233 or stanza:get_child("no-permanent-store", "urn:xmpp:hints")
235 or stanza:get_child("no-storage", "urn:xmpp:hints") 234 or stanza:get_child("no-storage", "urn:xmpp:hints")
236 or stanza:get_child("no-store", "urn:xmpp:hints") then 235 or stanza:get_child("no-store", "urn:xmpp:hints") then
237 module:log("debug", "Not archiving stanza: %s (content)", stanza:top_tag()); 236 module:log("debug", "Not archiving stanza: %s (hint)", stanza:top_tag());
238 return; 237 return;
239 end 238 end
240 239
241 -- Whos storage do we put it in? 240 -- Whos storage do we put it in?
242 local store_user = c2s and origin.username or jid_split(orig_to); 241 local store_user = c2s and origin.username or jid_split(orig_to);