]> granicus.if.org Git - ejabberd/commitdiff
Let is_carbon_copy/1 recognize <received/> carbons
authorHolger Weiss <holger@zedat.fu-berlin.de>
Fri, 30 May 2014 21:36:02 +0000 (23:36 +0200)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Fri, 30 May 2014 21:36:02 +0000 (23:36 +0200)
The mod_carboncopy:is_carbon_copy/1 function now returns true not only
for <sent/>, but also for <received/> carbon copies.

src/mod_carboncopy.erl

index 009d17ed26e0c10bb0757321062af9436bc5e29a..4cf3bed71f1803632c61291a53bac87aa4a93743 100644 (file)
                    version :: binary() | matchspec_atom()}).
 
 is_carbon_copy(Packet) ->
-       case xml:get_subtag(Packet, <<"sent">>) of
-               #xmlel{name= <<"sent">>, attrs = AAttrs}  ->
-               case xml:get_attr_s(<<"xmlns">>, AAttrs) of
-                               ?NS_CC_2 -> true;
-                               ?NS_CC_1 -> true;
-                               _ -> false
-                       end;
+    is_carbon_copy(Packet, <<"sent">>) orelse
+       is_carbon_copy(Packet, <<"received">>).
+
+is_carbon_copy(Packet, Direction) ->
+    case xml:get_subtag(Packet, Direction) of
+       #xmlel{name = Direction, attrs = Attrs} ->
+           case xml:get_attr_s(<<"xmlns">>, Attrs) of
+               ?NS_CC_2 -> true;
+               ?NS_CC_1 -> true;
                _ -> false
-       end.
+           end;
+       _ -> false
+    end.
 
 start(Host, Opts) ->
     IQDisc = gen_mod:get_opt(iqdisc, Opts,fun gen_iq_handler:check_type/1, one_queue),