1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-01-03 14:57:42 -05:00

OMEMO: Fix precondition-not-met handling

This commit is contained in:
Paul Fariello 2021-08-19 09:57:19 +02:00
parent d8cee98cc7
commit 4d93df4aba
2 changed files with 15 additions and 6 deletions

View File

@ -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;

View File

@ -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"