aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/database.cpp22
-rw-r--r--lib/database.h2
-rw-r--r--lib/room.cpp4
3 files changed, 13 insertions, 15 deletions
diff --git a/lib/database.cpp b/lib/database.cpp
index 3255e5e7..0119b35c 100644
--- a/lib/database.cpp
+++ b/lib/database.cpp
@@ -346,20 +346,18 @@ QOlmOutboundGroupSessionPtr Database::loadCurrentOutboundMegolmSession(const QSt
return nullptr;
}
-void Database::setDevicesReceivedKey(const QString& roomId, const QHash<QString, QList<std::pair<QString, QString>>>& devices, const QString& sessionId, int index)
+void Database::setDevicesReceivedKey(const QString& roomId, const QVector<std::tuple<QString, QString, QString>>& devices, const QString& sessionId, int index)
{
transaction();
- for (const auto& user : devices.keys()) {
- for (const auto& [device, curveKey] : devices[user]) {
- auto query = prepareQuery(QStringLiteral("INSERT INTO sent_megolm_sessions(roomId, userId, deviceId, identityKey, sessionId, i) VALUES(:roomId, :userId, :deviceId, :identityKey, :sessionId, :i);"));
- query.bindValue(":roomId", roomId);
- query.bindValue(":userId", user);
- query.bindValue(":deviceId", device);
- query.bindValue(":identityKey", curveKey);
- query.bindValue(":sessionId", sessionId);
- query.bindValue(":i", index);
- execute(query);
- }
+ for (const auto& [user, device, curveKey] : devices) {
+ auto query = prepareQuery(QStringLiteral("INSERT INTO sent_megolm_sessions(roomId, userId, deviceId, identityKey, sessionId, i) VALUES(:roomId, :userId, :deviceId, :identityKey, :sessionId, :i);"));
+ query.bindValue(":roomId", roomId);
+ query.bindValue(":userId", user);
+ query.bindValue(":deviceId", device);
+ query.bindValue(":identityKey", curveKey);
+ query.bindValue(":sessionId", sessionId);
+ query.bindValue(":i", index);
+ execute(query);
}
commit();
}
diff --git a/lib/database.h b/lib/database.h
index 8bef332f..ef251d66 100644
--- a/lib/database.h
+++ b/lib/database.h
@@ -46,7 +46,7 @@ public:
// Returns a map UserId -> [DeviceId] that have not received key yet
QHash<QString, QStringList> devicesWithoutKey(const QString& roomId, QHash<QString, QStringList>& devices, const QString &sessionId);
- void setDevicesReceivedKey(const QString& roomId, const QHash<QString, QList<std::pair<QString, QString>>>& devices, const QString& sessionId, int index);
+ void setDevicesReceivedKey(const QString& roomId, const QVector<std::tuple<QString, QString, QString>>& devices, const QString& sessionId, int index);
private:
void migrateTo1();
diff --git a/lib/room.cpp b/lib/room.cpp
index 5d3ae329..3696f808 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -537,10 +537,10 @@ public:
}
if (!usersToDevicesToEvents.empty()) {
connection->sendToDevices("m.room.encrypted", usersToDevicesToEvents);
- QHash<QString, QList<std::pair<QString, QString>>> receivedDevices;
+ QVector<std::tuple<QString, QString, QString>> receivedDevices;
for (const auto& user : devices.keys()) {
for (const auto& device : devices[user]) {
- receivedDevices[user] += {device, q->connection()->curveKeyForUserDevice(user, device) };
+ receivedDevices += {user, device, q->connection()->curveKeyForUserDevice(user, device) };
}
}
connection->database()->setDevicesReceivedKey(q->id(), receivedDevices, sessionId, index);