Fix broken olm channels automatically

This commit is contained in:
Nicolas Werner 2021-04-13 23:42:18 +02:00
parent 8108d98fa7
commit 99314c948e
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 22 additions and 2 deletions

View file

@ -361,7 +361,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare(
MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
GIT_TAG 808605299937203696a572c585a51509b1de28cf
GIT_TAG 5b7654c5d4512abc38806a0f44efc199029ceef4
)
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")

View file

@ -148,7 +148,7 @@ modules:
buildsystem: cmake-ninja
name: mtxclient
sources:
- commit: 7194b4f058406b1c10d3741d83abcf2d8963d849
- commit: 5b7654c5d4512abc38806a0f44efc199029ceef4
type: git
url: https://github.com/Nheko-Reborn/mtxclient.git
- config-opts:

View file

@ -359,6 +359,26 @@ handle_olm_message(const OlmMessage &msg)
return;
}
}
try {
auto otherUserDeviceKeys = cache::userKeys(msg.sender);
if (!otherUserDeviceKeys)
return;
std::map<std::string, std::vector<std::string>> targets;
for (auto [device_id, key] : otherUserDeviceKeys->device_keys) {
if (key.keys.at("curve25519:" + device_id) == msg.sender_key)
targets[msg.sender].push_back(device_id);
}
send_encrypted_to_device_messages(
targets, mtx::events::DeviceEvent<mtx::events::msg::Dummy>{}, true);
nhlog::crypto()->info(
"Recovering from broken olm channel with {}:{}", msg.sender, msg.sender_key);
} catch (std::exception &e) {
nhlog::crypto()->error("Failed to recover from broken olm sessions: {}", e.what());
}
}
nlohmann::json