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:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-05-31 01:44:19 +0400
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-05-31 01:44:19 +0400
commitf45654a16a8f8b1c7704c55d9da23422d083b459 (patch)
tree149ab544406541668f64456b0848bd73fefea6e9 /src/mod_carboncopy.erl
parentbb952f9ecc7dac549ace3ac0d02cb5621e1749e8 (diff)
Simplify mod_carboncopy:check_and_forward/4
Use the existing is_carbon_copy/1 function, and combine multiple case clauses into a single one.
Diffstat (limited to 'src/mod_carboncopy.erl')
-rw-r--r--src/mod_carboncopy.erl52
1 files changed, 14 insertions, 38 deletions
diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl
index 4cf3bed71..9c8494bba 100644
--- a/src/mod_carboncopy.erl
+++ b/src/mod_carboncopy.erl
@@ -143,44 +143,20 @@ user_receive_packet(JID, _From, To, Packet) ->
% - do not support "private" message mode, and do not modify the original packet in any way
% - we also replicate "read" notifications
check_and_forward(JID, To, #xmlel{name = <<"message">>, attrs = Attrs} = Packet, Direction)->
- case xml:get_attr_s(<<"type">>, Attrs) of
- <<"chat">> ->
- case xml:get_subtag(Packet, <<"private">>) of
- false ->
- case xml:get_subtag(Packet, <<"no-copy">>) of
- false ->
- case xml:get_subtag(Packet,<<"received">>) of
- false ->
- %% 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, To, Packet, Direction);
- true ->
- case xml:get_subtag(Packet,<<"forwarded">>) of
- false->
- case xml:get_subtag(SubTag,<<"forwarded">>) of
- false ->
- send_copies(JID, To, Packet, Direction);
- _ ->
- stop
- end;
- _ ->
- stop
- end
- end;
- _ ->
- %% stop the hook chain, we don't want mod_logdb to register this message (duplicate)
- stop
- end;
- _ ->
- ok
- end;
- _ ->
- ok
- end;
- _ ->
- ok
+ case xml:get_attr_s(<<"type">>, Attrs) == <<"chat">> andalso
+ xml:get_subtag(Packet, <<"private">>) == false andalso
+ xml:get_subtag(Packet, <<"no-copy">>) == false of
+ true ->
+ case is_carbon_copy(Packet) of
+ false ->
+ send_copies(JID, To, Packet, Direction);
+ true ->
+ %% stop the hook chain, we don't want mod_logdb to register
+ %% this message (duplicate)
+ stop
+ end;
+ _ ->
+ ok
end;
check_and_forward(_JID, _To, _Packet, _)-> ok.