diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-11-06 03:36:56 +0100 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2022-11-06 03:36:56 +0100 |
commit | 537fa437e2cf7aae82d3e066cfc26b4149652523 (patch) | |
tree | d0533cecb4e18c69288e740c20afa9dfeaa4f52c /src/encryption | |
parent | 1f77e1c810ad8b47cb40cb59e52b01fe534652b7 (diff) |
Store secrets (apart from the pickle key) in the database
Diffstat (limited to 'src/encryption')
-rw-r--r-- | src/encryption/Olm.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/encryption/Olm.cpp b/src/encryption/Olm.cpp index a9d5b1c2..a1d311e1 100644 --- a/src/encryption/Olm.cpp +++ b/src/encryption/Olm.cpp @@ -6,6 +6,7 @@ #include "Olm.h" #include <QObject> +#include <QRandomGenerator> #include <QTimer> #include <nlohmann/json.hpp> @@ -98,13 +99,19 @@ handle_secret_request(const mtx::events::DeviceEvent<mtx::events::msg::SecretReq return; secretSend.content.secret = secret.value(); - send_encrypted_to_device_messages( - {{local_user.to_string(), {{e->content.requesting_device_id}}}}, secretSend); - - nhlog::net()->info("Sent secret '{}' to ({},{})", - e->content.name, - local_user.to_string(), - e->content.requesting_device_id); + // Randomly delay reply to workaround olm session generation races + QTimer::singleShot(QRandomGenerator::global()->bounded(0, 3000), + ChatPage::instance(), + [local_user, e = *e, secretSend] { + send_encrypted_to_device_messages( + {{local_user.to_string(), {{e.content.requesting_device_id}}}}, + secretSend); + + nhlog::net()->info("Sent secret '{}' to ({},{})", + e.content.name, + local_user.to_string(), + e.content.requesting_device_id); + }); } void |