]> granicus.if.org Git - ejabberd/commitdiff
#148 Carbon copy sends message back to original sender solved
authoriulianlaz <iulianlaz@gmail.com>
Thu, 6 Mar 2014 08:40:38 +0000 (08:40 +0000)
committeriulianlaz <iulianlaz@gmail.com>
Thu, 6 Mar 2014 08:40:38 +0000 (08:40 +0000)
src/mod_carboncopy.erl

index cc5cb83b08d8b8421d7395d905a0a58400da66d3..ac1a1ef5634f7b8846c9325e5249cfb9ef56da30 100644 (file)
@@ -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