about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-10-06 22:32:58 +0200
committerMichael Vetter <jubalh@iodoru.org>2019-10-06 22:32:58 +0200
commit147be3afdfd2f87e989450bf0cddddfa9e817e24 (patch)
tree29e79a23fc9b10836e43e4f997cfba79f14106fb
parent7d7997e93c281cbaa532492005fd269a9ab0d808 (diff)
downloadprofani-tty-147be3afdfd2f87e989450bf0cddddfa9e817e24.tar.gz
Don't log own messages on incoming MUC
`sv_ev_room_message()` called `groupchat_log_msg_in()` to log all
incoming MUC messages.

`cl_ev_send_muc_msg()` calls `groupchat_log_msg_out()`.

So messages sent by the user himself was logged two times.

Filter the incoming messages and only log the ones not from our occupant
jid/nick.

Fix https://github.com/profanity-im/profanity/issues/1201
-rw-r--r--src/event/server_events.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 96b0611f..0417f35d 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -294,10 +294,13 @@ sv_ev_room_message(ProfMessage *message)
 
     char *mynick = muc_nick(mucwin->roomjid);
 
-    if (message->enc == PROF_MSG_ENC_OMEMO) {
-        groupchat_log_omemo_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
-    } else {
-        groupchat_log_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
+    // only log messages from others. we log our own via mucwin_outgoing_msg()
+    if (g_strcmp0(mynick, message->jid->resourcepart) != 0) {
+        if (message->enc == PROF_MSG_ENC_OMEMO) {
+            groupchat_log_omemo_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
+        } else {
+            groupchat_log_msg_in(message->jid->barejid, message->jid->resourcepart, message->plain);
+        }
     }
 
     char *old_plain = message->plain;