about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/omemo/omemo.c13
-rw-r--r--src/omemo/omemo.h2
2 files changed, 12 insertions, 3 deletions
diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c
index 9300c6b8..3ab044ee 100644
--- a/src/omemo/omemo.c
+++ b/src/omemo/omemo.c
@@ -173,9 +173,18 @@ omemo_prekeys(GList ** const prekeys, GList ** const ids, GList ** const lengths
 }
 
 void
-omemo_set_device_list(const char *const jid, GList * const device_list)
+omemo_set_device_list(const char *const jid, GList * device_list)
 {
-    /* TODO handle self device_list to ensure we still are on the list */
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+    char *barejid = xmpp_jid_bare(ctx, session_get_account_name());
+
+    if (g_strcmp0(jid, barejid) == 0) {
+        if (!g_list_find(device_list, GINT_TO_POINTER(omemo_ctx.device_id))) {
+            device_list = g_list_append(device_list, GINT_TO_POINTER(omemo_ctx.device_id));
+            omemo_devicelist_publish(device_list);
+        }
+    }
+
     g_hash_table_insert(omemo_ctx.device_list, strdup(jid), device_list);
 }
 
diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h
index ca9f7208..31d942b8 100644
--- a/src/omemo/omemo.h
+++ b/src/omemo/omemo.h
@@ -12,7 +12,7 @@ void omemo_identity_key(unsigned char **output, size_t *length);
 void omemo_signed_prekey(unsigned char **output, size_t *length);
 void omemo_signed_prekey_signature(unsigned char **output, size_t *length);
 void omemo_prekeys(GList ** const prekeys, GList ** const ids, GList ** const lengths);
-void omemo_set_device_list(const char *const jid, GList * const device_list);
+void omemo_set_device_list(const char *const jid, GList * device_list);
 
 void omemo_start_session(ProfAccount *account, char *barejid);
 gboolean omemo_loaded(void);