From 0dfb0b9c6b70c33449b2414ab769785fdbd71a27 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Thu, 6 Nov 2014 00:56:55 +0100 Subject: [PATCH] mod_message_log: Ignore "empty" carbon copies Just as we ignore regular messages that don't include a non-empty , we now ignore carbon copies of such messages. --- mod_message_log/src/mod_message_log.erl | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/mod_message_log/src/mod_message_log.erl b/mod_message_log/src/mod_message_log.erl index f4d8eef..1cfed17 100644 --- a/mod_message_log/src/mod_message_log.erl +++ b/mod_message_log/src/mod_message_log.erl @@ -110,21 +110,22 @@ is_carbon(Packet) -> {Direction, SubTag} = case {xml:get_subtag(Packet, <<"sent">>), xml:get_subtag(Packet, <<"received">>)} of {false, false} -> - {none, none}; + {false, false}; {false, Tag} -> {incoming, Tag}; {Tag, _} -> {outgoing, Tag} end, - if SubTag =:= none -> - false; - true -> - case xml:get_subtag(SubTag, <<"forwarded">>) of - false -> - false; - _ -> - {true, Direction} - end + F = fun(_, false) -> + false; + (Name, Tag) -> + xml:get_subtag(Tag, Name) + end, + case lists:foldl(F, SubTag, [<<"forwarded">>, <<"message">>, <<"body">>]) of + #xmlel{children = Body} when length(Body) > 0 -> + {true, Direction}; + _ -> + false end. loop(Config) ->