aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-05-06 12:48:09 +0200
committerKim Alvefur <zash@zash.se>2020-05-06 12:48:09 +0200
commit39aa6b37284d7c45a38001e6076e536b67ca044c (patch)
tree2a3f78253e7bd298b43c1400dda3ab7307296f4c /plugins
parent405ba6df12d248331d74dfb8ec93bc1321b9056a (diff)
downloadprosody-39aa6b37284d7c45a38001e6076e536b67ca044c.tar.gz
prosody-39aa6b37284d7c45a38001e6076e536b67ca044c.zip
mod_carbons: Clarify handling of error bounces
The :find bit was hard to understand, this should be clearer.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_carbons.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/mod_carbons.lua b/plugins/mod_carbons.lua
index fad47a7c..f07e9356 100644
--- a/plugins/mod_carbons.lua
+++ b/plugins/mod_carbons.lua
@@ -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 @@ local function should_copy(stanza, c2s, user_bare)
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