Fix comparison for glare algorithm

This commit is contained in:
Nicolas Werner 2022-06-12 19:09:07 +02:00
parent 00740a7e65
commit 62b3b461ec
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
2 changed files with 9 additions and 5 deletions

View file

@ -15,6 +15,7 @@
#include <QDateTime>
#include <QTimer>
#include <iostream>
#include <tuple>
static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
@ -569,10 +570,10 @@ DeviceVerificationFlow::handleStartMessage(const mtx::events::msg::KeyVerificati
this->canonical_json = nlohmann::json(msg);
else {
// resolve glare
if (utils::localUser().toStdString() > this->toClient.to_string() &&
http::client()->device_id() > this->deviceId.toStdString()) {
// treat this as if the user with the smaller mxid and deviceid was the sender of
// "start"
if (std::tuple(this->toClient.to_string(), this->deviceId.toStdString()) <
std::tuple(utils::localUser().toStdString(), http::client()->device_id())) {
// treat this as if the user with the smaller mxid or smaller deviceid (if the mxid
// was the same) was the sender of "start"
this->canonical_json = nlohmann::json(msg);
this->sender = false;
}