From ab4991e8297bf1055bee64d7eca9651b010046bf Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 10 Dec 2021 22:25:34 +0100 Subject: 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. --- plugins/mod_mam/mod_mam.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'plugins/mod_mam') diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua index afbd6500..92b49fcd 100644 --- a/plugins/mod_mam/mod_mam.lua +++ b/plugins/mod_mam/mod_mam.lua @@ -24,6 +24,7 @@ local prefs_to_stanza = module:require"mamprefsxml".tostanza; local prefs_from_stanza = module:require"mamprefsxml".fromstanza; local jid_bare = require "util.jid".bare; local jid_split = require "util.jid".split; +local jid_resource = require "util.jid".resource; local jid_prepped_split = require "util.jid".prepped_split; local dataform = require "util.dataforms".new; local get_form_type = require "util.dataforms".get_type; @@ -320,8 +321,17 @@ local function should_store(stanza, c2s) --> boolean, reason: string return false, "headline"; end if st_type == "error" and not c2s then - -- Store delivery failure notifications so you know if your own messages were not delivered - return true, "bounce"; + -- Errors not sent sent from a local client + -- Why would a client send an error anyway? + if jid_resource(stanza.attr.to) then + -- Store delivery failure notifications so you know if your own messages + -- were not delivered. + return true, "bounce"; + else + -- Skip errors for messages that come from your account, such as PEP + -- notifications. + return false, "bounce"; + end end if st_type == "groupchat" then -- MUC messages always go to the full JID, usually archived by the MUC -- cgit v1.2.3