Request unknown message indices

This commit is contained in:
Nicolas Werner 2021-01-23 20:08:59 +01:00
parent 049278bc35
commit 7bc57f76f7
5 changed files with 23 additions and 10 deletions

View file

@ -890,12 +890,15 @@ decryptEvent(const MegolmSessionIndex &index,
std::string msg_str;
try {
auto session = cache::client()->getInboundMegolmSession(index);
auto res =
olm::client()->decrypt_group_message(session.get(), event.content.ciphertext);
msg_str = std::string((char *)res.data.data(), res.data.size());
} catch (const lmdb::error &e) {
return {DecryptionErrorCode::DbError, e.what(), std::nullopt};
} 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};
}