diff options
author | Paul Fariello <paul@fariello.eu> | 2021-08-18 18:12:15 +0200 |
---|---|---|
committer | Paul Fariello <paul@fariello.eu> | 2021-08-19 10:02:07 +0200 |
commit | d8cee98cc7ce1d76f340c0a24389b32689aea578 (patch) | |
tree | 2e1eab9fe300dfc75b7dd9e5007cca104b5cdbfc /src/xmpp | |
parent | 0b6cf20183b07b8d3a9c09356e2365d4a21803f7 (diff) | |
download | profani-tty-d8cee98cc7ce1d76f340c0a24389b32689aea578.tar.gz |
Create devicelist if it doesn't exists
Diffstat (limited to 'src/xmpp')
-rw-r--r-- | src/xmpp/omemo.c | 19 |
1 files changed, 18 insertions, 1 deletions
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); |