Don't publish keys if the server doesn't support pubsub.

Related-to: https://github.com/profanity-im/profanity/issues/2078
Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-11-18 13:13:48 +01:00
parent 1d508d592c
commit 01c781fcf6
2 changed files with 9 additions and 10 deletions

View File

@@ -346,8 +346,6 @@ omemo_generate_crypto_materials(ProfAccount* account)
void void
omemo_publish_crypto_materials(void) omemo_publish_crypto_materials(void)
{ {
log_debug("[OMEMO] publish crypto materials");
if (omemo_ctx.loaded != TRUE) { if (omemo_ctx.loaded != TRUE) {
cons_show("OMEMO: cannot publish crypto materials before they are generated"); cons_show("OMEMO: cannot publish crypto materials before they are generated");
log_error("[OMEMO] cannot publish crypto materials before they are generated"); log_error("[OMEMO] cannot publish crypto materials before they are generated");

View File

@@ -116,6 +116,11 @@ omemo_devicelist_request(const char* const jid)
void void
omemo_bundle_publish(gboolean first) omemo_bundle_publish(gboolean first)
{ {
if (!connection_supports(XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) {
cons_show("OMEMO: Cannot publish bundle: no PUBSUB feature announced");
log_debug("[OMEMO] Cannot publish bundle: no PUBSUB feature announced");
return;
}
log_debug("[OMEMO] publish own OMEMO bundle"); log_debug("[OMEMO] publish own OMEMO bundle");
xmpp_ctx_t* const ctx = connection_get_ctx(); xmpp_ctx_t* const ctx = connection_get_ctx();
unsigned char* identity_key = NULL; unsigned char* identity_key = NULL;
@@ -141,14 +146,10 @@ omemo_bundle_publish(gboolean first)
g_list_free(lengths); g_list_free(lengths);
g_list_free(ids); g_list_free(ids);
if (connection_supports(XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) {
stanza_attach_publish_options_va(ctx, iq, stanza_attach_publish_options_va(ctx, iq,
4, // 2 * number of key-value pairs 4, // 2 * number of key-value pairs
"pubsub#persist_items", "true", "pubsub#persist_items", "true",
"pubsub#access_model", "open"); "pubsub#access_model", "open");
} else {
log_debug("[OMEMO] Cannot publish bundle: no PUBSUB feature announced");
}
iq_id_handler_add(id, _omemo_bundle_publish_result, NULL, GINT_TO_POINTER(first)); iq_id_handler_add(id, _omemo_bundle_publish_result, NULL, GINT_TO_POINTER(first));