From d8cee98cc7ce1d76f340c0a24389b32689aea578 Mon Sep 17 00:00:00 2001 From: Paul Fariello Date: Wed, 18 Aug 2021 18:12:15 +0200 Subject: Create devicelist if it doesn't exists --- src/xmpp/omemo.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/xmpp') diff --git a/src/xmpp/omemo.c b/src/xmpp/omemo.c index e0f79c9e..05882936 100644 --- a/src/xmpp/omemo.c +++ b/src/xmpp/omemo.c @@ -459,8 +459,25 @@ out: static int _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata) { - GList* device_list = NULL; const char* from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); + const char* type = xmpp_stanza_get_type(stanza); + + GList* device_list = NULL; + + if (g_strcmp0(type, STANZA_TYPE_ERROR) == 0) { + log_error("[OMEMO] can't get OMEMO device list"); + xmpp_stanza_t* error = xmpp_stanza_get_child_by_name(stanza, "error"); + if (!error) { + log_error("[OMEMO] missing error element in device list response"); + return 1; + } + + const char* code = xmpp_stanza_get_attribute(error, "code"); + if (g_strcmp0(code, "404") == 0) { + omemo_set_device_list(from, device_list); + return 1; + } + } xmpp_stanza_t* root = NULL; xmpp_stanza_t* event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT); -- cgit 1.4.1-2-gfad0