mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Request unknown message indices
This commit is contained in:
parent
049278bc35
commit
7bc57f76f7
5 changed files with 23 additions and 10 deletions
|
@ -355,7 +355,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
MatrixClient
|
MatrixClient
|
||||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
GIT_TAG v0.4.0
|
GIT_TAG 1e97d3195d366a15a086ca451d082d59972105ba
|
||||||
)
|
)
|
||||||
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
||||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
|
@ -220,8 +220,7 @@
|
||||||
"name": "mtxclient",
|
"name": "mtxclient",
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"commit": "2d6e3f79917ce2065a54ca32e6a9f9d42c0b6347",
|
"commit": "1e97d3195d366a15a086ca451d082d59972105ba",
|
||||||
"tag": "v0.4.0",
|
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Nheko-Reborn/mtxclient.git"
|
"url": "https://github.com/Nheko-Reborn/mtxclient.git"
|
||||||
}
|
}
|
||||||
|
|
|
@ -890,12 +890,15 @@ decryptEvent(const MegolmSessionIndex &index,
|
||||||
std::string msg_str;
|
std::string msg_str;
|
||||||
try {
|
try {
|
||||||
auto session = cache::client()->getInboundMegolmSession(index);
|
auto session = cache::client()->getInboundMegolmSession(index);
|
||||||
|
|
||||||
auto res =
|
auto res =
|
||||||
olm::client()->decrypt_group_message(session.get(), event.content.ciphertext);
|
olm::client()->decrypt_group_message(session.get(), event.content.ciphertext);
|
||||||
msg_str = std::string((char *)res.data.data(), res.data.size());
|
msg_str = std::string((char *)res.data.data(), res.data.size());
|
||||||
} catch (const lmdb::error &e) {
|
} catch (const lmdb::error &e) {
|
||||||
return {DecryptionErrorCode::DbError, e.what(), std::nullopt};
|
return {DecryptionErrorCode::DbError, e.what(), std::nullopt};
|
||||||
} catch (const mtx::crypto::olm_exception &e) {
|
} catch (const mtx::crypto::olm_exception &e) {
|
||||||
|
if (e.error_code() == mtx::crypto::OlmErrorCode::UNKNOWN_MESSAGE_INDEX)
|
||||||
|
return {DecryptionErrorCode::MissingSessionIndex, e.what(), std::nullopt};
|
||||||
return {DecryptionErrorCode::DecryptionFailed, e.what(), std::nullopt};
|
return {DecryptionErrorCode::DecryptionFailed, e.what(), std::nullopt};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@ enum class DecryptionErrorCode
|
||||||
{
|
{
|
||||||
MissingSession, // Session was not found, retrieve from backup or request from other devices
|
MissingSession, // Session was not found, retrieve from backup or request from other devices
|
||||||
// and try again
|
// and try again
|
||||||
DbError, // DB read failed
|
MissingSessionIndex, // Session was found, but it does not reach back enough to this index,
|
||||||
|
// retrieve from backup or request from other devices and try again
|
||||||
|
DbError, // DB read failed
|
||||||
DecryptionFailed, // libolm error
|
DecryptionFailed, // libolm error
|
||||||
ParsingFailed, // Failed to parse the actual event
|
ParsingFailed, // Failed to parse the actual event
|
||||||
ReplayAttack, // Megolm index reused
|
ReplayAttack, // Megolm index reused
|
||||||
|
|
|
@ -543,12 +543,21 @@ EventStore::decryptEvent(const IdIndex &idx,
|
||||||
|
|
||||||
if (decryptionResult.error) {
|
if (decryptionResult.error) {
|
||||||
switch (*decryptionResult.error) {
|
switch (*decryptionResult.error) {
|
||||||
case olm::DecryptionErrorCode::MissingSession: {
|
case olm::DecryptionErrorCode::MissingSession:
|
||||||
dummy.content.body =
|
case olm::DecryptionErrorCode::MissingSessionIndex: {
|
||||||
tr("-- Encrypted Event (No keys found for decryption) --",
|
if (decryptionResult.error == olm::DecryptionErrorCode::MissingSession)
|
||||||
"Placeholder, when the message was not decrypted yet or can't be "
|
dummy.content.body =
|
||||||
"decrypted.")
|
tr("-- Encrypted Event (No keys found for decryption) --",
|
||||||
.toStdString();
|
"Placeholder, when the message was not decrypted yet or can't "
|
||||||
|
"be "
|
||||||
|
"decrypted.")
|
||||||
|
.toStdString();
|
||||||
|
else
|
||||||
|
dummy.content.body =
|
||||||
|
tr("-- Encrypted Event (Key not valid for this index) --",
|
||||||
|
"Placeholder, when the message can't be decrypted with this "
|
||||||
|
"key since it is not valid for this index ")
|
||||||
|
.toStdString();
|
||||||
nhlog::crypto()->info("Could not find inbound megolm session ({}, {}, {})",
|
nhlog::crypto()->info("Could not find inbound megolm session ({}, {}, {})",
|
||||||
index.room_id,
|
index.room_id,
|
||||||
index.session_id,
|
index.session_id,
|
||||||
|
|
Loading…
Reference in a new issue