mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Save the olm account after we create new one-time keys
Otherwise after a restart the old account will be loaded and we won't be able to decrypt messages from devices using the new one-time keys. Also new one-time key upload requests will fail due to conflicts with the existing keys with the same keyid.
This commit is contained in:
parent
4514d13948
commit
604cdcec8a
3 changed files with 15 additions and 2 deletions
|
@ -75,4 +75,7 @@ encrypt_group_message(const std::string &room_id,
|
|||
const std::string &device_id,
|
||||
const std::string &body);
|
||||
|
||||
void
|
||||
mark_keys_as_published();
|
||||
|
||||
} // namespace olm
|
||||
|
|
|
@ -1038,7 +1038,8 @@ ChatPage::tryInitialSync()
|
|||
return;
|
||||
}
|
||||
|
||||
olm::client()->mark_keys_as_published();
|
||||
olm::mark_keys_as_published();
|
||||
|
||||
for (const auto &entry : res.one_time_key_counts)
|
||||
nhlog::net()->info(
|
||||
"uploaded {} {} one-time keys", entry.second, entry.first);
|
||||
|
@ -1273,7 +1274,7 @@ ChatPage::ensureOneTimeKeyCount(const std::map<std::string, uint16_t> &counts)
|
|||
return;
|
||||
}
|
||||
|
||||
olm::client()->mark_keys_as_published();
|
||||
olm::mark_keys_as_published();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
using namespace mtx::crypto;
|
||||
|
||||
static const std::string STORAGE_SECRET_KEY("secret");
|
||||
|
||||
namespace {
|
||||
auto client_ = std::make_unique<mtx::crypto::OlmClient>();
|
||||
}
|
||||
|
@ -229,4 +231,11 @@ create_inbound_megolm_session(const std::string &sender,
|
|||
nhlog::crypto()->info("established inbound megolm session ({}, {})", room_id, sender);
|
||||
}
|
||||
|
||||
void
|
||||
mark_keys_as_published()
|
||||
{
|
||||
olm::client()->mark_keys_as_published();
|
||||
cache::client()->saveOlmAccount(olm::client()->save(STORAGE_SECRET_KEY));
|
||||
}
|
||||
|
||||
} // namespace olm
|
||||
|
|
Loading…
Reference in a new issue