make sure that no http requests are done inside of /sync

This commit is contained in:
Sorunome 2020-07-26 07:54:03 +02:00
parent 3fae58439b
commit 14c8377a2f
No known key found for this signature in database
GPG Key ID: B19471D07FC9BE9C
2 changed files with 9 additions and 3 deletions

View File

@ -72,12 +72,16 @@ class Encryption {
}
Future<void> handleToDeviceEvent(ToDeviceEvent event) async {
if (['m.room_key', 'm.room_key_request', 'm.forwarded_room_key']
.contains(event.type)) {
// a new room key or thelike. We need to handle this asap, before other
if (event.type == 'm.room_key') {
// a new room key. We need to handle this asap, before other
// events in /sync are handled
await keyManager.handleToDeviceEvent(event);
}
if (['m.room_key_request', 'm.forwarded_room_key'].contains(event.type)) {
// "just" room key request things. We don't need these asap, so we handle
// them in the background
unawaited(keyManager.handleToDeviceEvent(event));
}
if (event.type.startsWith('m.key.verification.')) {
// some key verification event. No need to handle it now, we can easily
// do this in the background

View File

@ -123,6 +123,8 @@ class KeyManager {
json.encode(content),
json.encode({}),
);
// Note to self: When adding key-backup that needs to be unawaited(), else
// we might accidentally end up with http requests inside of the sync loop
// TODO: somehow try to decrypt last message again
final room = client.getRoomById(roomId);
if (room != null) {