aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 0ef27486..4c614176 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -117,6 +117,7 @@ public:
bool encryptionUpdateRequired = false;
PicklingMode picklingMode = Unencrypted {};
Database *database = nullptr;
+ QHash<QString, int> oneTimeKeysCount;
// A map from SenderKey to vector of InboundSession
UnorderedMap<QString, std::vector<QOlmSessionPtr>> olmSessions;
@@ -755,13 +756,12 @@ QJsonObject toJson(const DirectChatsMap& directChats)
void Connection::onSyncSuccess(SyncData&& data, bool fromCache)
{
#ifdef Quotient_E2EE_ENABLED
- const auto oneTimeKeyCount =
- static_cast<size_t>(data.deviceOneTimeKeysCount()[SignedCurve25519Key]);
- if (oneTimeKeyCount < 0.4 * d->olmAccount->maxNumberOfOneTimeKeys()
+ d->oneTimeKeysCount = data.deviceOneTimeKeysCount();
+ if (d->oneTimeKeysCount[SignedCurve25519Key] < 0.4 * d->olmAccount->maxNumberOfOneTimeKeys()
&& !d->isUploadingKeys) {
d->isUploadingKeys = true;
d->olmAccount->generateOneTimeKeys(
- d->olmAccount->maxNumberOfOneTimeKeys() / 2 - oneTimeKeyCount);
+ d->olmAccount->maxNumberOfOneTimeKeys() / 2 - d->oneTimeKeysCount[SignedCurve25519Key]);
auto keys = d->olmAccount->oneTimeKeys();
auto job = d->olmAccount->createUploadKeyRequest(keys);
run(job, ForegroundRequest);
@@ -1829,6 +1829,10 @@ void Connection::saveState() const
QJsonObject {
{ QStringLiteral("events"), accountDataEvents } });
}
+ {
+ QJsonObject keysJson = toJson(d->oneTimeKeysCount);
+ rootObj.insert(QStringLiteral("device_one_time_keys_count"), keysJson);
+ }
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
const auto data =