about summary refs log tree commit diff stats
path: root/src/event
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-04-11 23:56:01 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-04-11 23:56:01 +0200
commitdd566d8d561099bbfc81b2fab22318bbad0cf3da (patch)
tree2e32e9ff2a68d02dda146cf8897174553112d24b /src/event
parent180ec2b474b39de0b22964adbfc5e13bc3d2c791 (diff)
downloadprofani-tty-dd566d8d561099bbfc81b2fab22318bbad0cf3da.tar.gz
MAM: Correctly display incoming MAM chat message
Diffstat (limited to 'src/event')
-rw-r--r--src/event/server_events.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index 11b5d877..057af9bf 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -622,16 +622,30 @@ void
 sv_ev_incoming_message(ProfMessage *message)
 {
     gboolean new_win = FALSE;
-    ProfChatWin *chatwin = wins_get_chat(message->from_jid->barejid);
+    ProfChatWin *chatwin;
+    char *looking_for_jid = message->from_jid->barejid;
+
+    if (message->is_mam) {
+        Jid *my_jid = jid_create(connection_get_fulljid());
+        if (g_strcmp0(my_jid->barejid, message->from_jid->barejid) == 0) {
+            looking_for_jid = message->to_jid->barejid;
+        }
+        jid_destroy(my_jid);
+    }
+
+    chatwin = wins_get_chat(looking_for_jid);
+
     if (!chatwin) {
-        ProfWin *window = wins_new_chat(message->from_jid->barejid);
+        ProfWin *window = wins_new_chat(looking_for_jid);
         chatwin = (ProfChatWin*)window;
         new_win = TRUE;
 
 #ifdef HAVE_OMEMO
-        if (omemo_automatic_start(message->from_jid->barejid)) {
-            omemo_start_session(message->from_jid->barejid);
-            chatwin->is_omemo = TRUE;
+        if (!message->is_mam) {
+            if (omemo_automatic_start(message->from_jid->barejid)) {
+                omemo_start_session(message->from_jid->barejid);
+                chatwin->is_omemo = TRUE;
+            }
         }
 #endif
     }