1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Ensure received devicelist contains our own device id

This commit is contained in:
Paul Fariello 2019-02-25 06:04:03 +01:40
parent 756fefb09a
commit 95da03ac28
2 changed files with 12 additions and 3 deletions

View File

@ -173,9 +173,18 @@ omemo_prekeys(GList ** const prekeys, GList ** const ids, GList ** const lengths
} }
void 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); g_hash_table_insert(omemo_ctx.device_list, strdup(jid), device_list);
} }

View File

@ -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(unsigned char **output, size_t *length);
void omemo_signed_prekey_signature(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_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); void omemo_start_session(ProfAccount *account, char *barejid);
gboolean omemo_loaded(void); gboolean omemo_loaded(void);