1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Acquire sender's device list on connection

After generation of an identity we observe that `omemo_ctx.device_list`
has an entry for sender's jid. But on application restart it is absent
thus messages are not encrypted for the rest set of sender devices.

This commit fixes this by applying code for acquiring the aforementioned device list after the connection.
This commit is contained in:
nandesu-utils 2021-10-28 04:01:07 +09:00
parent b4d65335f6
commit 17d62921e9
No known key found for this signature in database
GPG Key ID: EA19BE17F9C938B7

View File

@ -84,6 +84,7 @@ static unsigned char* _omemo_fingerprint_decode(const char* const fingerprint, s
static char* _omemo_unformat_fingerprint(const char* const fingerprint_formatted); static char* _omemo_unformat_fingerprint(const char* const fingerprint_formatted);
static void _cache_device_identity(const char* const jid, uint32_t device_id, ec_public_key* identity); static void _cache_device_identity(const char* const jid, uint32_t device_id, ec_public_key* identity);
static void _g_hash_table_free(GHashTable* hash_table); static void _g_hash_table_free(GHashTable* hash_table);
static void _omemo_sender_devices(void);
typedef gboolean (*OmemoDeviceListHandler)(const char* const jid, GList* device_list); typedef gboolean (*OmemoDeviceListHandler)(const char* const jid, GList* device_list);
@ -303,6 +304,9 @@ omemo_on_connect(ProfAccount* account)
log_warning("[OMEMO] no such file: %s", omemo_ctx.trust_filename->str); log_warning("[OMEMO] no such file: %s", omemo_ctx.trust_filename->str);
g_error_free(error); g_error_free(error);
} }
log_debug("[OMEMO] Acquiring sender devices for current account");
_omemo_sender_devices();
} }
void void
@ -384,15 +388,15 @@ omemo_publish_crypto_materials(void)
return; return;
} }
omemo_bundle_publish(true);
}
static void _omemo_sender_devices(void) {
char* barejid = connection_get_barejid(); char* barejid = connection_get_barejid();
/* Ensure we get our current device list, and it gets updated with our
* device_id */
g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_own_device_list); g_hash_table_insert(omemo_ctx.device_list_handler, strdup(barejid), _handle_own_device_list);
omemo_devicelist_request(barejid); omemo_devicelist_request(barejid);
omemo_bundle_publish(true);
free(barejid); free(barejid);
} }