From 9ef1ad0b6e44c2e41c2086e70253cbf5538b90c6 Mon Sep 17 00:00:00 2001 From: iulianlaz Date: Thu, 6 Mar 2014 08:40:38 +0000 Subject: #148 Carbon copy sends message back to original sender solved --- src/mod_carboncopy.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/mod_carboncopy.erl') diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl index cc5cb83b0..ac1a1ef56 100644 --- a/src/mod_carboncopy.erl +++ b/src/mod_carboncopy.erl @@ -151,7 +151,19 @@ check_and_forward(JID, #xmlel{name = <<"message">>, attrs = Attrs} = Packet, Dir false -> case xml:get_subtag(Packet,<<"received">>) of false -> - send_copies(JID, Packet, Direction); + %% We must check if a packet contains "" tags in order to avoid + %% receiving message back to original sender. + SubTag = xml:get_subtag(Packet,<<"sent">>), + if SubTag == false -> + send_copies(JID, Packet, Direction); + true -> + case xml:get_subtag(SubTag,<<"forwarded">>) of + false-> + send_copies(JID, Packet, Direction); + _ -> + stop + end + end; _ -> %% stop the hook chain, we don't want mod_logdb to register this message (duplicate) stop -- cgit v1.2.3