# HG changeset patch # User Kim Alvefur # Date 1588762089 -7200 # Node ID c11f9cd6c761d7c32ee10369b3d742c23f1ae605 # Parent 2b97aac0ea3c72871e2b28a91377486d96a24303 mod_carbons: Clarify handling of error bounces The :find bit was hard to understand, this should be clearer. diff -r 2b97aac0ea3c -r c11f9cd6c761 plugins/mod_carbons.lua --- a/plugins/mod_carbons.lua Tue May 05 23:08:47 2020 +0200 +++ b/plugins/mod_carbons.lua Wed May 06 12:48:09 2020 +0200 @@ -5,10 +5,15 @@ local st = require "util.stanza"; local jid_bare = require "util.jid".bare; +local jid_resource = require "util.jid".resource; local xmlns_carbons = "urn:xmpp:carbons:2"; local xmlns_forward = "urn:xmpp:forward:0"; local full_sessions, bare_sessions = prosody.full_sessions, prosody.bare_sessions; +local function is_bare(jid) + return not jid_resource(jid); +end + local function toggle_carbons(event) local origin, stanza = event.origin, event.stanza; local state = stanza.tags[1].name; @@ -43,7 +48,10 @@ return true, "type"; end - if st_type == "error" and not c2s and not (stanza.attr.from or ""):find("/") then + -- Normal outgoing chat messages are sent to=bare JID. This clause should + -- match the error bounces from those, which would have from=bare JID and + -- be incoming (not c2s). + if st_type == "error" and not c2s and is_bare(stanza.attr.from) then return true, "bounce"; end