Comparison

plugins/mod_mam/mod_mam.lua @ 10773:3e1046b39484

mod_mam: Store only incoming errors Unclear if clients normally ever send error messages, but there may be locally generated bounces sent on behalf of local sessions.
author Kim Alvefur <zash@zash.se>
date Sun, 26 Apr 2020 14:28:00 +0200
parent 10752:930f38939f1e
child 10800:62794e065e33
comparison
equal deleted inserted replaced
10772:31e702c5f475 10773:3e1046b39484
261 end); 261 end);
262 end 262 end
263 return stanza; 263 return stanza;
264 end 264 end
265 265
266 local function should_store(stanza) --> boolean, reason: string 266 local function should_store(stanza, c2s) --> boolean, reason: string
267 local st_type = stanza.attr.type or "normal"; 267 local st_type = stanza.attr.type or "normal";
268 -- FIXME pass direction of stanza and use that along with bare/full JID addressing 268 -- FIXME pass direction of stanza and use that along with bare/full JID addressing
269 -- for more accurate MUC / type=groupchat check 269 -- for more accurate MUC / type=groupchat check
270 270
271 if st_type == "headline" then 271 if st_type == "headline" then
272 -- Headline messages are ephemeral by definition 272 -- Headline messages are ephemeral by definition
273 return false, "headline"; 273 return false, "headline";
274 end 274 end
275 if st_type == "error" then 275 if st_type == "error" and not c2s then
276 -- Store delivery failure notifications so you know if your own messages were not delivered
276 return true, "bounce"; 277 return true, "bounce";
277 end 278 end
278 if st_type == "groupchat" then 279 if st_type == "groupchat" then
279 -- MUC messages always go to the full JID, usually archived by the MUC 280 -- MUC messages always go to the full JID, usually archived by the MUC
280 return false, "groupchat"; 281 return false, "groupchat";
332 local with = jid_bare(c2s and orig_to or orig_from); 333 local with = jid_bare(c2s and orig_to or orig_from);
333 334
334 -- Filter out <stanza-id> that claim to be from us 335 -- Filter out <stanza-id> that claim to be from us
335 event.stanza = strip_stanza_id(stanza, store_user); 336 event.stanza = strip_stanza_id(stanza, store_user);
336 337
337 local should, why = should_store(stanza); 338 local should, why = should_store(stanza, c2s);
338 if not should then 339 if not should then
339 log("debug", "Not archiving stanza: %s (%s)", stanza:top_tag(), why); 340 log("debug", "Not archiving stanza: %s (%s)", stanza:top_tag(), why);
340 return; 341 return;
341 end 342 end
342 343