diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-05-16 17:38:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 17:38:34 +0200 |
commit | 77b190d822c1e980b98b84999f0cfb609ed05a49 (patch) | |
tree | 049fc3936343a7af957c0bca20dd1531ae2e5f81 /lib/room.cpp | |
parent | 0599ef6e603dce219b2ba000d7322e8d937753b9 (diff) | |
parent | decc676f1e469dc26c80c33da64fad15805de8f2 (diff) | |
download | libquotient-77b190d822c1e980b98b84999f0cfb609ed05a49.tar.gz libquotient-77b190d822c1e980b98b84999f0cfb609ed05a49.zip |
Merge #550: Quotient::Expected and QOlmExpected
Diffstat (limited to 'lib/room.cpp')
-rw-r--r-- | lib/room.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index db49e80f..1314803e 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -380,17 +380,22 @@ public: return {}; } auto decryptResult = senderSession->decrypt(cipher); - if(std::holds_alternative<QOlmError>(decryptResult)) { + if(!decryptResult) { qCWarning(E2EE) << "Unable to decrypt event" << eventId - << "with matching megolm session:" << std::get<QOlmError>(decryptResult); + << "with matching megolm session:" << decryptResult.error(); return {}; } - const auto& [content, index] = std::get<std::pair<QString, uint32_t>>(decryptResult); - const auto& [recordEventId, ts] = q->connection()->database()->groupSessionIndexRecord(q->id(), senderSession->sessionId(), index); + const auto& [content, index] = *decryptResult; + const auto& [recordEventId, ts] = + q->connection()->database()->groupSessionIndexRecord( + q->id(), senderSession->sessionId(), index); if (recordEventId.isEmpty()) { - q->connection()->database()->addGroupSessionIndexRecord(q->id(), senderSession->sessionId(), index, eventId, timestamp.toMSecsSinceEpoch()); + q->connection()->database()->addGroupSessionIndexRecord( + q->id(), senderSession->sessionId(), index, eventId, + timestamp.toMSecsSinceEpoch()); } else { - if ((eventId != recordEventId) || (ts != timestamp.toMSecsSinceEpoch())) { + if ((eventId != recordEventId) + || (ts != timestamp.toMSecsSinceEpoch())) { qCWarning(E2EE) << "Detected a replay attack on event" << eventId; return {}; } |