Comparison

plugins/mod_mam/mod_mam.lua @ 12030:9f8206e99b89

mod_mam: Avoid storing bounces for messages from the bare account (thanks Ge0rG) This should rule out error replies to PEP notifications, which come from the account bare JID, and would be reflected back to it if they can't be delivered for some reason, e.g. s2s problems.
author Kim Alvefur <zash@zash.se>
date Fri, 10 Dec 2021 22:25:34 +0100
parent 11988:18c0ca5fcbb8
child 12234:1c47162dd965
comparison
equal deleted inserted replaced
12029:631b2afa7bc1 12030:9f8206e99b89
22 local set_prefs = module:require"mamprefs".set; 22 local set_prefs = module:require"mamprefs".set;
23 local prefs_to_stanza = module:require"mamprefsxml".tostanza; 23 local prefs_to_stanza = module:require"mamprefsxml".tostanza;
24 local prefs_from_stanza = module:require"mamprefsxml".fromstanza; 24 local prefs_from_stanza = module:require"mamprefsxml".fromstanza;
25 local jid_bare = require "util.jid".bare; 25 local jid_bare = require "util.jid".bare;
26 local jid_split = require "util.jid".split; 26 local jid_split = require "util.jid".split;
27 local jid_resource = require "util.jid".resource;
27 local jid_prepped_split = require "util.jid".prepped_split; 28 local jid_prepped_split = require "util.jid".prepped_split;
28 local dataform = require "util.dataforms".new; 29 local dataform = require "util.dataforms".new;
29 local get_form_type = require "util.dataforms".get_type; 30 local get_form_type = require "util.dataforms".get_type;
30 local host = module.host; 31 local host = module.host;
31 32
318 if st_type == "headline" then 319 if st_type == "headline" then
319 -- Headline messages are ephemeral by definition 320 -- Headline messages are ephemeral by definition
320 return false, "headline"; 321 return false, "headline";
321 end 322 end
322 if st_type == "error" and not c2s then 323 if st_type == "error" and not c2s then
323 -- Store delivery failure notifications so you know if your own messages were not delivered 324 -- Errors not sent sent from a local client
324 return true, "bounce"; 325 -- Why would a client send an error anyway?
326 if jid_resource(stanza.attr.to) then
327 -- Store delivery failure notifications so you know if your own messages
328 -- were not delivered.
329 return true, "bounce";
330 else
331 -- Skip errors for messages that come from your account, such as PEP
332 -- notifications.
333 return false, "bounce";
334 end
325 end 335 end
326 if st_type == "groupchat" then 336 if st_type == "groupchat" then
327 -- MUC messages always go to the full JID, usually archived by the MUC 337 -- MUC messages always go to the full JID, usually archived by the MUC
328 return false, "groupchat"; 338 return false, "groupchat";
329 end 339 end