about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorPaul Fariello <paul@fariello.eu>2021-08-19 09:57:19 +0200
committerPaul Fariello <paul@fariello.eu>2021-08-19 10:02:07 +0200
commit4d93df4aba232c6999a8edd6fd0fbdc0174f9e07 (patch)
treefbe7eebe56db68d5380c9a10d2e121c2f234f181 /src
parentd8cee98cc7ce1d76f340c0a24389b32689aea578 (diff)
downloadprofani-tty-4d93df4aba232c6999a8edd6fd0fbdc0174f9e07.tar.gz
OMEMO: Fix precondition-not-met handling
Diffstat (limited to 'src')
-rw-r--r--src/xmpp/omemo.c19
-rw-r--r--src/xmpp/stanza.h2
2 files changed, 15 insertions, 6 deletions
diff --git a/src/xmpp/omemo.c b/src/xmpp/omemo.c
index 05882936..3db6337d 100644
--- a/src/xmpp/omemo.c
+++ b/src/xmpp/omemo.c
@@ -474,8 +474,7 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
 
         const char* code = xmpp_stanza_get_attribute(error, "code");
         if (g_strcmp0(code, "404") == 0) {
-            omemo_set_device_list(from, device_list);
-            return 1;
+            goto out;
         }
     }
 
@@ -521,7 +520,7 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
         log_warning("[OMEMO] User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(first));
         item = first;
     } else {
-        return 1;
+        goto out;
     }
 
     xmpp_stanza_t* list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
@@ -543,6 +542,7 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
         }
     }
 
+out:
     omemo_set_device_list(from, device_list);
 
     return 1;
@@ -553,7 +553,6 @@ _omemo_devicelist_publish_result(xmpp_stanza_t* const stanza, void* const userda
 {
     const char* type = xmpp_stanza_get_type(stanza);
     if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) {
-        cons_show_error("Unable to publish own OMEMO device list");
         log_error("[OMEMO] Publishing device list failed");
 
         xmpp_stanza_t *error = xmpp_stanza_get_child_by_name(stanza, "error");
@@ -564,11 +563,21 @@ _omemo_devicelist_publish_result(xmpp_stanza_t* const stanza, void* const userda
 
         xmpp_stanza_t *pubsub_error = xmpp_stanza_get_child_by_ns(error, STANZA_NS_PUBSUB_ERROR);
         if (!pubsub_error) {
+            // TODO
             return 0;
         }
 
         if (g_strcmp0(xmpp_stanza_get_name(pubsub_error), "precondition-not-met") == 0) {
-            omemo_devicelist_configure();
+            static gboolean reconfigured = false;
+            if (!reconfigured) {
+                reconfigured = true;
+                cons_show_error("Unable to publish own OMEMO device list, reconfiguring node");
+                log_error("[OMEMO] Unable to publish own OMEMO device list, reconfiguring node");
+                omemo_devicelist_configure();
+            } else {
+                cons_show_error("Unable to publish own OMEMO device list, previous reconfiguration failed. Giving up.");
+                log_error("[OMEMO] Unable to publish own OMEMO device list, previous reconfiguration failed. Giving up.");
+            }
         }
     }
     return 0;
diff --git a/src/xmpp/stanza.h b/src/xmpp/stanza.h
index 7a95629e..c58395bb 100644
--- a/src/xmpp/stanza.h
+++ b/src/xmpp/stanza.h
@@ -216,7 +216,7 @@
 #define STANZA_NS_PUBSUB       "http://jabber.org/protocol/pubsub"
 #define STANZA_NS_PUBSUB_OWNER "http://jabber.org/protocol/pubsub#owner"
 #define STANZA_NS_PUBSUB_EVENT "http://jabber.org/protocol/pubsub#event"
-#define STANZA_NS_PUBSUB_ERROR "http://jabber.org/protocol/pubsub#error"
+#define STANZA_NS_PUBSUB_ERROR "http://jabber.org/protocol/pubsub#errors"
 #define STANZA_NS_CARBONS      "urn:xmpp:carbons:2"
 #define STANZA_NS_HINTS        "urn:xmpp:hints"
 #define STANZA_NS_FORWARD      "urn:xmpp:forward:0"