about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-06-09 10:08:21 +0200
committerGitHub <noreply@github.com>2021-06-09 10:08:21 +0200
commitd7adec69cefedce8949ead1309e9a8e56a8c4d8f (patch)
treed36fdd6965680fb541875a2294c6e0e9459e1a53
parentefcb0c31ea70858ceeab1b692895fefeeb2aaf57 (diff)
parent8fe95399a1c2f530b9a64f2dd864d55712fa4f6a (diff)
downloadprofani-tty-d7adec69cefedce8949ead1309e9a8e56a8c4d8f.tar.gz
Merge pull request #1553 from DebXWoody/bugfix/fix1552
OMEMO: Separate handling of device list

Two changes: 
* First register the handler before sending the request
* Don't add own jid to handler
-rw-r--r--src/omemo/omemo.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index 9b2b35f5..efc3dbfe 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -367,6 +367,8 @@ omemo_generate_crypto_materials(ProfAccount* account)
 void
 omemo_publish_crypto_materials(void)
 {
+    log_debug("[OMEMO] publish crypto materials");
+
     if (loaded != TRUE) {
         cons_show("OMEMO: cannot publish crypto materials before they are generated");
         log_error("[OMEMO] cannot publish crypto materials before they are generated");
@@ -408,8 +410,14 @@ omemo_start_session(const char* const barejid)
         GList* device_list = g_hash_table_lookup(omemo_ctx.device_list, barejid);
         if (!device_list) {
             log_debug("[OMEMO] missing device list for %s", barejid);
+            // Own devices are handled by _handle_own_device_list
+            // We won't add _handle_device_list_start_session for ourself
+            char* mybarejid = connection_get_barejid();
+            if( g_strcmp0(mybarejid, barejid ) != 0 ) {
+                g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_device_list_start_session);
+            }
+            free(mybarejid);
             omemo_devicelist_request(barejid);
-            g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_device_list_start_session);
             return;
         }
 
@@ -525,6 +533,7 @@ omemo_prekeys(GList** prekeys, GList** ids, GList** lengths)
 void
 omemo_set_device_list(const char* const from, GList* device_list)
 {
+    log_debug("[OMEMO] Setting device list for %s", from);
     Jid* jid;
     if (from) {
         jid = jid_create(from);
@@ -540,6 +549,8 @@ omemo_set_device_list(const char* const from, GList* device_list)
         if (!keep) {
             g_hash_table_remove(omemo_ctx.device_list_handler, jid->barejid);
         }
+    } else {
+        log_debug("[OMEMO] No Device List Handler for %s", from);
     }
 
     // OMEMO trustmode ToFu