summary refs log tree commit diff
path: root/src/timeline
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-08-17 03:23:51 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-08-17 03:24:12 +0200
commit56db0dbc7d0878ce1621a4dc998024d470d200a5 (patch)
treefc941d540e26a6d2b5ae9ae67d04944d3f66c3a0 /src/timeline
parentUpdate translations (diff)
downloadnheko-56db0dbc7d0878ce1621a4dc998024d470d200a5.tar.xz
Allow downloading keys from key backup
Diffstat (limited to 'src/timeline')
-rw-r--r--src/timeline/EventStore.cpp7
-rw-r--r--src/timeline/TimelineModel.cpp10
2 files changed, 7 insertions, 10 deletions
diff --git a/src/timeline/EventStore.cpp b/src/timeline/EventStore.cpp

index 742f8dbb..8860bc75 100644 --- a/src/timeline/EventStore.cpp +++ b/src/timeline/EventStore.cpp
@@ -643,10 +643,7 @@ EventStore::decryptEvent(const IdIndex &idx, if (auto cachedEvent = decryptedEvents_.object(idx)) return cachedEvent; - MegolmSessionIndex index; - index.room_id = room_id_; - index.session_id = e.content.session_id; - index.sender_key = e.content.sender_key; + MegolmSessionIndex index(room_id_, e.content); auto asCacheEntry = [&idx](olm::DecryptionResult &&event) { auto event_ptr = new olm::DecryptionResult(std::move(event)); @@ -726,6 +723,7 @@ EventStore::requestSession(const mtx::events::EncryptedEvent<mtx::events::msg::E qint64 delay = manual ? 60 : (60 * 10); if (r.requested_at + delay < QDateTime::currentSecsSinceEpoch()) { r.requested_at = QDateTime::currentSecsSinceEpoch(); + olm::lookup_keybackup(room_id_, ev.content.session_id); olm::send_key_request_for(copy, r.request_id); } } else { @@ -733,6 +731,7 @@ EventStore::requestSession(const mtx::events::EncryptedEvent<mtx::events::msg::E request.request_id = "key_request." + http::client()->generate_txn_id(); request.requested_at = QDateTime::currentSecsSinceEpoch(); request.events.push_back(copy); + olm::lookup_keybackup(room_id_, ev.content.session_id); olm::send_key_request_for(copy, request.request_id); pending_key_requests[ev.content.session_id] = request; } diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 79c28edf..88d575fa 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -641,8 +641,9 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r if (auto encrypted = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( &*encrypted_event)) { - return olm::calculate_trust(encrypted->sender, - encrypted->content.sender_key); + return olm::calculate_trust( + encrypted->sender, + MegolmSessionIndex(room_id_.toStdString(), encrypted->content)); } } return crypto::Trust::Unverified; @@ -840,10 +841,7 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline) for (auto e : timeline.events) { if (auto encryptedEvent = std::get_if<EncryptedEvent<msg::Encrypted>>(&e)) { - MegolmSessionIndex index; - index.room_id = room_id_.toStdString(); - index.session_id = encryptedEvent->content.session_id; - index.sender_key = encryptedEvent->content.sender_key; + MegolmSessionIndex index(room_id_.toStdString(), encryptedEvent->content); auto result = olm::decryptEvent(index, *encryptedEvent); if (result.event)