aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorTobias Fella <9750016+TobiasFella@users.noreply.github.com>2021-11-27 00:11:36 +0100
committerTobias Fella <fella@posteo.de>2021-12-01 21:56:59 +0100
commite99802772ebab9802e2f35d83ce1de9f83691d90 (patch)
treec6bca54892f6f7de4e092d5ce2112a3a8a6fc52e /lib/room.cpp
parente4802dc967c640ebac1d0bc7db55b47b79233544 (diff)
downloadlibquotient-e99802772ebab9802e2f35d83ce1de9f83691d90.tar.gz
libquotient-e99802772ebab9802e2f35d83ce1de9f83691d90.zip
Apply suggestions from code review
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 65ce82ac..fca1912f 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -456,7 +456,7 @@ public:
return false;
}
qCWarning(E2EE) << "Adding inbound session";
- groupSessions[qMakePair(senderKey, sessionId)] = std::move(megolmSession);
+ groupSessions[{senderKey, sessionId}] = std::move(megolmSession);
saveMegOlmSessions();
return true;
}
@@ -469,13 +469,14 @@ public:
{
QPair<QString, QString> senderSessionPairKey =
qMakePair(senderKey, sessionId);
- if (groupSessions.find(senderSessionPairKey) == groupSessions.end()) {
+ auto groupSessionIt = groupSessions.find(senderSessionPairKey);
+ if (groupSessionIt == groupSessions.end()) {
qCWarning(E2EE) << "Unable to decrypt event" << eventId
<< "The sender's device has not sent us the keys for "
"this message";
return QString();
}
- auto& senderSession = groupSessions[senderSessionPairKey];
+ auto& senderSession = *groupSessionIt;
auto decryptResult = senderSession->decrypt(cipher);
if(std::holds_alternative<QOlmError>(decryptResult)) {
qCWarning(E2EE) << "Unable to decrypt event" << eventId
@@ -520,8 +521,6 @@ Room::Room(Connection* connection, QString id, JoinState initialJoinState)
emit baseStateLoaded();
return this == r; // loadedRoomState fires only once per room
});
- qCDebug(STATE) << "New" << initialJoinState << "Room:" << id;
-
#ifdef Quotient_E2EE_ENABLED
connectSingleShot(this, &Room::encryption, this, [=](){
connection->encryptionUpdate(this);
@@ -1555,7 +1554,7 @@ RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent)
qCWarning(E2EE) << "Encrypted message is empty";
return {};
}
- QJsonObject eventObject = QJsonDocument::fromJson(decrypted.toUtf8()).object();
+ auto eventObject = QJsonDocument::fromJson(decrypted.toUtf8()).object();
eventObject["event_id"] = encryptedEvent.id();
eventObject["sender"] = encryptedEvent.senderId();
eventObject["origin_server_ts"] = encryptedEvent.originTimestamp().toMSecsSinceEpoch();