From e8b8a8d52eeb82a4cde38d8e43cc245960626f5f Mon Sep 17 00:00:00 2001 From: "jabber.developer2" Date: Tue, 31 Mar 2026 19:46:19 +0300 Subject: [PATCH] fix: don't publish OMEMO keys if server doesn't support pubsub (upstream 01c781fc) --- src/omemo/omemo.c | 2 -- src/xmpp/omemo.c | 17 +++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 74fc923c..72a8b105 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -352,8 +352,6 @@ omemo_generate_crypto_materials(ProfAccount* account) void omemo_publish_crypto_materials(void) { - log_debug("[OMEMO] publish crypto materials"); - if (omemo_ctx.loaded != TRUE) { cons_show("OMEMO: cannot publish crypto materials before they are generated"); log_error("[OMEMO] cannot publish crypto materials before they are generated"); diff --git a/src/xmpp/omemo.c b/src/xmpp/omemo.c index b9b0faf3..fdb00ee4 100644 --- a/src/xmpp/omemo.c +++ b/src/xmpp/omemo.c @@ -116,6 +116,11 @@ omemo_devicelist_request(const char* const jid) void 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"); xmpp_ctx_t* const ctx = connection_get_ctx(); unsigned char* identity_key = NULL; @@ -141,14 +146,10 @@ omemo_bundle_publish(gboolean first) g_list_free(lengths); g_list_free(ids); - if (connection_supports(XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS)) { - stanza_attach_publish_options_va(ctx, iq, - 4, // 2 * number of key-value pairs - "pubsub#persist_items", "true", - "pubsub#access_model", "open"); - } else { - log_debug("[OMEMO] Cannot publish bundle: no PUBSUB feature announced"); - } + stanza_attach_publish_options_va(ctx, iq, + 4, // 2 * number of key-value pairs + "pubsub#persist_items", "true", + "pubsub#access_model", "open"); iq_id_handler_add(id, _omemo_bundle_publish_result, NULL, GINT_TO_POINTER(first));