diff options
author | badlop <badlop@ono.com> | 2014-03-16 23:59:49 +0400 |
---|---|---|
committer | badlop <badlop@ono.com> | 2014-03-16 23:59:49 +0400 |
commit | 2b527f5e9ae8ed867fc3b6c24f8b55f621e94663 (patch) | |
tree | 87b51ed015e5a5f7fdff698710d9680f036eaf8e /src/mod_carboncopy.erl | |
parent | 633d47f7845c6295f5c3cf46c3a92972713b4951 (diff) | |
parent | 9ef1ad0b6e44c2e41c2086e70253cbf5538b90c6 (diff) |
Merge pull request #149 from iulianlaz/carboncopy-fix-msg-back-to-original-sender
#148 Carbon copy sends message back to original sender solved
Diffstat (limited to 'src/mod_carboncopy.erl')
-rw-r--r-- | src/mod_carboncopy.erl | 14 |
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 |