diff --git a/include/Olm.hpp b/include/Olm.hpp index 6f871628d7f21768d177ecca3b5cce165aafd501..eb7f9061ab856e8011eda8c735b4f28e3dda0f04 100644 --- a/include/Olm.hpp +++ b/include/Olm.hpp @@ -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 diff --git a/src/ChatPage.cc b/src/ChatPage.cc index e543cdf98a4fe1c65451fe5c1da8e64a2a57d81e..cc9473e62020f1578fe8e327d51d1645e446c1d8 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -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(); }); } } diff --git a/src/Olm.cpp b/src/Olm.cpp index 5976c1c02f07ec81b609e70fbffa7d573918cd35..c426968f4db308b406768389f1864cadc7936d5d 100644 --- a/src/Olm.cpp +++ b/src/Olm.cpp @@ -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