Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mod_carboncopy.erl14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl
index d5d1db6c5..d31791cd5 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 "<sent><forwarded></sent></forwarded>" 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