1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Merge branch 'omemofix'

This commit is contained in:
Michael Vetter 2020-07-04 17:38:44 +02:00
commit bf170d6c91
2 changed files with 39 additions and 21 deletions

View File

@ -98,7 +98,6 @@ struct omemo_context_t {
GHashTable *pre_key_store; GHashTable *pre_key_store;
GHashTable *signed_pre_key_store; GHashTable *signed_pre_key_store;
identity_key_store_t identity_key_store; identity_key_store_t identity_key_store;
GHashTable *device_ids;
GString *identity_filename; GString *identity_filename;
GKeyFile *identity_keyfile; GKeyFile *identity_keyfile;
GString *trust_filename; GString *trust_filename;

View File

@ -441,9 +441,32 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
return 1; return 1;
} }
xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
if (item) { // Looking for "current" item - if there is no current, take the first item.
xmpp_stanza_t* first = NULL;
xmpp_stanza_t* current = NULL;
xmpp_stanza_t *item = xmpp_stanza_get_children(items);
while ( item ) {
if (g_strcmp0(xmpp_stanza_get_name(item), "item") == 0) {
first = item;
if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0 ) { if (g_strcmp0(xmpp_stanza_get_id(item), "current") == 0 ) {
current = item;
break;
}
}
item = xmpp_stanza_get_next(item);
}
if(current) {
item = current;
} else if( first ) {
log_warning("OMEMO: User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(first));
item = first;
} else {
return 1;
}
xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO); xmpp_stanza_t *list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
if (!list) { if (!list) {
return 1; return 1;
@ -462,10 +485,6 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
log_error("OMEMO: received device without ID"); log_error("OMEMO: received device without ID");
} }
} }
} else {
log_warning("OMEMO: User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(item));
}
}
omemo_set_device_list(from, device_list); omemo_set_device_list(from, device_list);