mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-31 01:50:47 +03:00
Fix edge case that could lead to no new one time keys being uploaded
This commit is contained in:
parent
ace16b8c4d
commit
a61678242b
1 changed files with 23 additions and 21 deletions
|
@ -929,19 +929,22 @@ ChatPage::currentPresence() const
|
|||
void
|
||||
ChatPage::ensureOneTimeKeyCount(const std::map<std::string, uint16_t> &counts)
|
||||
{
|
||||
for (const auto &entry : counts) {
|
||||
if (entry.second < MAX_ONETIME_KEYS) {
|
||||
const int nkeys = MAX_ONETIME_KEYS - entry.second;
|
||||
uint16_t count = 0;
|
||||
if (auto c = counts.find(mtx::crypto::SIGNED_CURVE25519); c != counts.end())
|
||||
count = c->second;
|
||||
|
||||
nhlog::crypto()->info("uploading {} {} keys", nkeys, entry.first);
|
||||
if (count < MAX_ONETIME_KEYS) {
|
||||
const int nkeys = MAX_ONETIME_KEYS - count;
|
||||
|
||||
nhlog::crypto()->info(
|
||||
"uploading {} {} keys", nkeys, mtx::crypto::SIGNED_CURVE25519);
|
||||
olm::client()->generate_one_time_keys(nkeys);
|
||||
|
||||
http::client()->upload_keys(
|
||||
olm::client()->create_upload_keys_request(),
|
||||
[](const mtx::responses::UploadKeys &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
nhlog::crypto()->warn(
|
||||
"failed to update one-time keys: {} {} {}",
|
||||
nhlog::crypto()->warn("failed to update one-time keys: {} {} {}",
|
||||
err->matrix_error.error,
|
||||
static_cast<int>(err->status_code),
|
||||
static_cast<int>(err->error_code));
|
||||
|
@ -955,7 +958,6 @@ ChatPage::ensureOneTimeKeyCount(const std::map<std::string, uint16_t> &counts)
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ChatPage::getProfileInfo()
|
||||
|
|
Loading…
Reference in a new issue