diff options
author | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-09-19 22:46:36 +0200 |
---|---|---|
committer | Holger Weiss <holger@zedat.fu-berlin.de> | 2016-09-19 22:46:36 +0200 |
commit | e7787e2f335c44a5f88fea6d15d1e3a83ad55204 (patch) | |
tree | a6cae60cdbda4e830980871dbe46d35d626b1495 /src | |
parent | When getting list of subscribed rooms, check all including temporary ones (#1... (diff) |
mod_carboncopy: Don't copy MUC PMs
Carbon copies of private MUC message are generally not desired,
especially not when multiple clients joined the room with the same nick.
In this case, the MUC service usually sends PMs to all joined resources
anyway, so carbon-copying those PMs would create duplicates.
Diffstat (limited to 'src')
-rw-r--r-- | src/mod_carboncopy.erl | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl index de8d8e1a7..e1e6d63a2 100644 --- a/src/mod_carboncopy.erl +++ b/src/mod_carboncopy.erl @@ -131,8 +131,9 @@ user_receive_packet(Packet, _C2SState, JID, _From, To) -> % - we also replicate "read" notifications check_and_forward(JID, To, Packet, Direction)-> case is_chat_message(Packet) andalso - fxml:get_subtag(Packet, <<"private">>) == false andalso - fxml:get_subtag(Packet, <<"no-copy">>) == false of + not is_muc_pm(To, Packet) andalso + fxml:get_subtag(Packet, <<"private">>) == false andalso + fxml:get_subtag(Packet, <<"no-copy">>) == false of true -> case is_carbon_copy(Packet) of false -> @@ -270,6 +271,11 @@ is_chat_message(#xmlel{name = <<"message">>} = Packet) -> end; is_chat_message(_Packet) -> false. +is_muc_pm(#jid{lresource = <<>>}, _Packet) -> + false; +is_muc_pm(_To, Packet) -> + fxml:get_subtag_with_xmlns(Packet, <<"x">>, ?NS_MUC_USER) =/= false. + has_non_empty_body(Packet) -> fxml:get_subtag_cdata(Packet, <<"body">>) =/= <<"">>. |