Store secrets (apart from the pickle key) in the database

This commit is contained in:
Nicolas Werner 2022-11-06 03:36:56 +01:00
parent 1f77e1c810
commit 537fa437e2
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
4 changed files with 106 additions and 57 deletions

View file

@ -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);
// 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);
nhlog::net()->info("Sent secret '{}' to ({},{})",
e.content.name,
local_user.to_string(),
e.content.requesting_device_id);
});
}
void