diff options
| author | Melvin Keskin <melvo@olomono.de> | 2023-03-11 20:21:59 +0100 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2023-03-13 16:16:08 +0100 |
| commit | af46ac9487caf54bb0783616af4e209b94b1cde5 (patch) | |
| tree | c05b3ec473e02a2cb88cb0570068d9301b2d0ec5 /src/omemo/QXmppOmemoManager.cpp | |
| parent | 64e29c129d7a47e5d128cd097c5c4f6cbd5b4328 (diff) | |
| download | qxmpp-af46ac9487caf54bb0783616af4e209b94b1cde5.tar.gz | |
Fix OMEMO device list processing as specified
Diffstat (limited to 'src/omemo/QXmppOmemoManager.cpp')
| -rw-r--r-- | src/omemo/QXmppOmemoManager.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/omemo/QXmppOmemoManager.cpp b/src/omemo/QXmppOmemoManager.cpp index d5d3af0a..a3ad12bb 100644 --- a/src/omemo/QXmppOmemoManager.cpp +++ b/src/omemo/QXmppOmemoManager.cpp @@ -1267,29 +1267,33 @@ bool Manager::handlePubSubEvent(const QDomElement &element, const QString &pubSu switch (event.eventType()) { // Items have been published. case QXmppPubSubEventBase::Items: { - const auto items = event.items(); - // Only process items if the event notification contains one. - // That is necessary because PubSub allows publishing without - // items leading to notification-only events. - if (!items.isEmpty()) { - const auto &deviceListItem = items.constFirst(); - if (deviceListItem.id() == QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::Current)) { - d->updateDevices(pubSubService, event.items().constFirst()); + // That is necessary because PubSub allows publishing without items leading to + // notification-only events. + if (const auto &items = event.items(); !items.isEmpty()) { + // Since the usage of the item ID \c QXmppPubSubManager::Current is only RECOMMENDED + // by \xep{0060, Publish-Subscribe} (PubSub) but not obligatory, an appropriate + // contact device list is determined. + // In case of the own device list node, it is sctrictly processed as a recommended + // singleton item and changed to fit that if needed. + const auto isOwnDeviceListNode = d->ownBareJid() == pubSubService; + if (isOwnDeviceListNode) { + const auto &deviceListItem = items.constFirst(); + if (deviceListItem.id() == QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::Current)) { + d->updateDevices(pubSubService, event.items().constFirst()); + } else { + d->handleIrregularDeviceListChanges(pubSubService); + } } else { - d->handleIrregularDeviceListChanges(pubSubService); + d->updateContactDevices(pubSubService, items); } } break; } - // Items have been retracted. + // Specific items are deleted. case QXmppPubSubEventBase::Retract: { - // Specific items are deleted. - const auto &retractedItem = event.retractIds().constFirst(); - if (retractedItem == QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::Current)) { - d->handleIrregularDeviceListChanges(pubSubService); - } + d->handleIrregularDeviceListChanges(pubSubService); } // All items are deleted. case QXmppPubSubEventBase::Purge: |
