aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-14 11:20:43 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-05-14 11:23:48 +0200
commit572b727b22d66a79431326c924236ef431fd972b (patch)
tree5c60030964cf8ca9d279cd66fcdc22bd1ac92b48 /lib/room.cpp
parentb32c1c27ae412d073a7e98bdaf22678bdc66ab23 (diff)
downloadlibquotient-572b727b22d66a79431326c924236ef431fd972b.tar.gz
libquotient-572b727b22d66a79431326c924236ef431fd972b.zip
Cleanup across the board
Mainly driven by clang-tidy and SonarCloud warnings (sadly, SonarCloud doesn't store historical reports so no link can be provided here).
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 993455be..0a997b9c 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -339,14 +339,16 @@ public:
#ifdef Quotient_E2EE_ENABLED
UnorderedMap<QString, QOlmInboundGroupSessionPtr> groupSessions;
- bool addInboundGroupSession(QString sessionId, QString sessionKey, const QString& senderId, const QString& olmSessionId)
+ bool addInboundGroupSession(QString sessionId, QByteArray sessionKey,
+ const QString& senderId,
+ const QString& olmSessionId)
{
- if (groupSessions.find(sessionId) != groupSessions.end()) {
+ if (groupSessions.contains(sessionId)) {
qCWarning(E2EE) << "Inbound Megolm session" << sessionId << "already exists";
return false;
}
- auto megolmSession = QOlmInboundGroupSession::create(sessionKey.toLatin1());
+ auto megolmSession = QOlmInboundGroupSession::create(sessionKey);
if (megolmSession->sessionId() != sessionId) {
qCWarning(E2EE) << "Session ID mismatch in m.room_key event";
return false;
@@ -354,13 +356,12 @@ public:
megolmSession->setSenderId(senderId);
megolmSession->setOlmSessionId(olmSessionId);
qCWarning(E2EE) << "Adding inbound session";
- connection->saveMegolmSession(q, megolmSession.get());
+ connection->saveMegolmSession(q, *megolmSession);
groupSessions[sessionId] = std::move(megolmSession);
return true;
}
QString groupSessionDecryptMessage(QByteArray cipher,
- const QString& senderKey,
const QString& sessionId,
const QString& eventId,
QDateTime timestamp,
@@ -1478,9 +1479,9 @@ RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent)
return {};
}
QString decrypted = d->groupSessionDecryptMessage(
- encryptedEvent.ciphertext(), encryptedEvent.senderKey(),
- encryptedEvent.sessionId(), encryptedEvent.id(),
- encryptedEvent.originTimestamp(), encryptedEvent.senderId());
+ encryptedEvent.ciphertext(), encryptedEvent.sessionId(),
+ encryptedEvent.id(), encryptedEvent.originTimestamp(),
+ encryptedEvent.senderId());
if (decrypted.isEmpty()) {
// qCWarning(E2EE) << "Encrypted message is empty";
return {};
@@ -1509,7 +1510,8 @@ void Room::handleRoomKeyEvent(const RoomKeyEvent& roomKeyEvent,
<< roomKeyEvent.algorithm() << "in m.room_key event";
}
if (d->addInboundGroupSession(roomKeyEvent.sessionId(),
- roomKeyEvent.sessionKey(), senderId, olmSessionId)) {
+ roomKeyEvent.sessionKey(), senderId,
+ olmSessionId)) {
qCWarning(E2EE) << "added new inboundGroupSession:"
<< d->groupSessions.size();
auto undecryptedEvents = d->undecryptedEvents[roomKeyEvent.sessionId()];