about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-06-03 15:43:56 +0200
committerGitHub <noreply@github.com>2021-06-03 15:43:56 +0200
commite1fbe3be90089d99d4996ff6e146e053124fb419 (patch)
treeb3bf44bfca5ab12f499f47a45ee253dc3686d8fc
parente9ef3cf1d26400b47a276c758edc87e15e2de50a (diff)
parent64bcc06259cc74e5a368c09092e3d4ad422bbcd0 (diff)
downloadprofani-tty-e1fbe3be90089d99d4996ff6e146e053124fb419.tar.gz
Merge pull request #1542 from DebXWoody/bugfix/fix1541
OMEMO: Don't encrypt to yourself (MUC)
-rw-r--r--src/omemo/omemo.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index 192d3d2a..9b2b35f5 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -791,6 +791,19 @@ omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_
                 .device_id = GPOINTER_TO_INT(device_ids_iter->data)
             };
 
+            // Don't encrypt for this device (according to
+            // <https://xmpp.org/extensions/xep-0384.html#encrypt>).
+            // Yourself as recipients in case of MUC
+            char* mybarejid = connection_get_barejid();
+            if ( !g_strcmp0(mybarejid, recipients_iter->data) ) {
+                if (GPOINTER_TO_INT(device_ids_iter->data) == omemo_ctx.device_id) {
+                    free(mybarejid);
+                    log_debug("[OMEMO][SEND] Skipping %d (my device) ", GPOINTER_TO_INT(device_ids_iter->data));
+                    continue;
+                }
+            }
+            free(mybarejid);
+
             log_debug("[OMEMO][SEND] recipients with device id %d for %s", GPOINTER_TO_INT(device_ids_iter->data), recipients_iter->data);
             res = session_cipher_create(&cipher, omemo_ctx.store, &address, omemo_ctx.signal);
             if (res != SG_SUCCESS ) {