diff --git a/src/Olm.cpp b/src/Olm.cpp index 40c87f9f..2c9ac5a3 100644 --- a/src/Olm.cpp +++ b/src/Olm.cpp @@ -1112,6 +1112,8 @@ send_encrypted_to_device_messages(const std::map, qint64> rateLimit; + nlohmann::json ev_json = std::visit([](const auto &e) { return json(e); }, event); std::map> keysToQuery; @@ -1164,7 +1166,6 @@ send_encrypted_to_device_messages(const std::map, qint64> rateLimit; auto currentTime = QDateTime::currentSecsSinceEpoch(); if (rateLimit.value(QPair(user, device)) + 60 * 60 * 10 < currentTime) { @@ -1320,7 +1321,8 @@ send_encrypted_to_device_messages(const std::mapclaim_keys(claims, BindPks(pks)); + if (!claims.one_time_keys.empty()) + http::client()->claim_keys(claims, BindPks(pks)); if (!keysToQuery.empty()) { mtx::requests::QueryKeys req; @@ -1397,9 +1399,25 @@ send_encrypted_to_device_messages(const std::mapwarn( + "Not creating new session with {}:{} " + "because of rate limit", + user.first, + device_id.get()); + continue; + } nhlog::net()->info("{}", device_id.get()); nhlog::net()->info(" curve25519 {}", pks.curve25519); @@ -1407,7 +1425,8 @@ send_encrypted_to_device_messages(const std::mapclaim_keys(claim_keys, BindPks(deviceKeys)); + if (!claim_keys.one_time_keys.empty()) + http::client()->claim_keys(claim_keys, BindPks(deviceKeys)); }); } }