mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
parent
7ecabcd614
commit
961c880d55
2 changed files with 41 additions and 13 deletions
|
@ -14,7 +14,7 @@ feels more like a mainstream chat app ([Riot], Telegram etc) and less like an IR
|
||||||
Most of the features you would expect from a chat application are missing right now
|
Most of the features you would expect from a chat application are missing right now
|
||||||
but we are getting close to a more feature complete client.
|
but we are getting close to a more feature complete client.
|
||||||
Specifically there is support for:
|
Specifically there is support for:
|
||||||
- E2EE encryption.
|
- E2E encryption.
|
||||||
- User registration.
|
- User registration.
|
||||||
- Creating, joining & leaving rooms.
|
- Creating, joining & leaving rooms.
|
||||||
- Sending & receiving invites.
|
- Sending & receiving invites.
|
||||||
|
|
|
@ -297,12 +297,13 @@ TimelineView::parseEncryptedEvent(const mtx::events::EncryptedEvent<mtx::events:
|
||||||
index.session_id = e.content.session_id;
|
index.session_id = e.content.session_id;
|
||||||
index.sender_key = e.content.sender_key;
|
index.sender_key = e.content.sender_key;
|
||||||
|
|
||||||
mtx::events::RoomEvent<mtx::events::msg::Text> dummy;
|
mtx::events::RoomEvent<mtx::events::msg::Notice> dummy;
|
||||||
dummy.origin_server_ts = e.origin_server_ts;
|
dummy.origin_server_ts = e.origin_server_ts;
|
||||||
dummy.event_id = e.event_id;
|
dummy.event_id = e.event_id;
|
||||||
dummy.sender = e.sender;
|
dummy.sender = e.sender;
|
||||||
dummy.content.body = "-- Encrypted Event (No keys found for decryption) --";
|
dummy.content.body = "-- Encrypted Event (No keys found for decryption) --";
|
||||||
|
|
||||||
|
try {
|
||||||
if (!cache::client()->inboundMegolmSessionExists(index)) {
|
if (!cache::client()->inboundMegolmSessionExists(index)) {
|
||||||
nhlog::crypto()->info("Could not find inbound megolm session ({}, {}, {})",
|
nhlog::crypto()->info("Could not find inbound megolm session ({}, {}, {})",
|
||||||
index.room_id,
|
index.room_id,
|
||||||
|
@ -311,11 +312,35 @@ TimelineView::parseEncryptedEvent(const mtx::events::EncryptedEvent<mtx::events:
|
||||||
// TODO: request megolm session_id & session_key from the sender.
|
// TODO: request megolm session_id & session_key from the sender.
|
||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
} catch (const lmdb::error &e) {
|
||||||
|
nhlog::db()->critical("failed to check megolm session's existence: {}", e.what());
|
||||||
|
dummy.content.body = "-- Decryption Error (failed to communicate with DB) --";
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string msg_str;
|
||||||
|
try {
|
||||||
auto session = cache::client()->getInboundMegolmSession(index);
|
auto session = cache::client()->getInboundMegolmSession(index);
|
||||||
auto res = olm::client()->decrypt_group_message(session, e.content.ciphertext);
|
auto res = olm::client()->decrypt_group_message(session, e.content.ciphertext);
|
||||||
|
msg_str = std::string((char *)res.data.data(), res.data.size());
|
||||||
const auto msg_str = std::string((char *)res.data.data(), res.data.size());
|
} catch (const lmdb::error &e) {
|
||||||
|
nhlog::db()->critical("failed to retrieve megolm session with index ({}, {}, {})",
|
||||||
|
index.room_id,
|
||||||
|
index.session_id,
|
||||||
|
index.sender_key,
|
||||||
|
e.what());
|
||||||
|
dummy.content.body =
|
||||||
|
"-- Decryption Error (failed to retrieve megolm keys from db) --";
|
||||||
|
return dummy;
|
||||||
|
} catch (const mtx::crypto::olm_exception &e) {
|
||||||
|
nhlog::crypto()->critical("failed to decrypt message with index ({}, {}, {}): {}",
|
||||||
|
index.room_id,
|
||||||
|
index.session_id,
|
||||||
|
index.sender_key,
|
||||||
|
e.what());
|
||||||
|
dummy.content.body = "-- Decryption Error (" + std::string(e.what()) + ") --";
|
||||||
|
return dummy;
|
||||||
|
}
|
||||||
|
|
||||||
// Add missing fields for the event.
|
// Add missing fields for the event.
|
||||||
json body = json::parse(msg_str);
|
json body = json::parse(msg_str);
|
||||||
|
@ -1301,10 +1326,13 @@ TimelineView::prepareEncryptedMessage(const PendingMessage &msg)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// TODO: Let the user know about the errors.
|
||||||
} catch (const lmdb::error &e) {
|
} catch (const lmdb::error &e) {
|
||||||
nhlog::db()->critical(
|
nhlog::db()->critical(
|
||||||
"failed to open outbound megolm session ({}): {}", room_id, e.what());
|
"failed to open outbound megolm session ({}): {}", room_id, e.what());
|
||||||
return;
|
} catch (const mtx::crypto::olm_exception &e) {
|
||||||
|
nhlog::crypto()->critical(
|
||||||
|
"failed to open outbound megolm session ({}): {}", room_id, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue