summary refs log tree commit diff
path: root/src/Cache.cc
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-06-12 22:35:10 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-06-12 22:35:10 +0300
commite5dd64c63a04df6f0b885c737cc73b383e79bd67 (patch)
tree973755bc13c716dd866f35cc531afb9bd734974b /src/Cache.cc
parentFix bug where cache was initialized twice in a row (diff)
downloadnheko-e5dd64c63a04df6f0b885c737cc73b383e79bd67.tar.xz
Add method to convert PendingMessage's to event types
Add more logging during message sending
Diffstat (limited to 'src/Cache.cc')
-rw-r--r--src/Cache.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Cache.cc b/src/Cache.cc

index abc6fae4..35ad8f9d 100644 --- a/src/Cache.cc +++ b/src/Cache.cc
@@ -251,12 +251,11 @@ Cache::inboundMegolmSessionExists(const MegolmSessionIndex &index) noexcept } void -Cache::saveOutboundMegolmSession(const MegolmSessionIndex &index, +Cache::saveOutboundMegolmSession(const std::string &room_id, const OutboundGroupSessionData &data, mtx::crypto::OutboundGroupSessionPtr session) { using namespace mtx::crypto; - const auto key = index.to_hash(); const auto pickled = pickle<OutboundSessionObject>(session.get(), SECRET); json j; @@ -264,13 +263,13 @@ Cache::saveOutboundMegolmSession(const MegolmSessionIndex &index, j["session"] = pickled; auto txn = lmdb::txn::begin(env_); - lmdb::dbi_put(txn, outboundMegolmSessionDb_, lmdb::val(key), lmdb::val(j.dump())); + lmdb::dbi_put(txn, outboundMegolmSessionDb_, lmdb::val(room_id), lmdb::val(j.dump())); txn.commit(); { std::unique_lock<std::mutex> lock(session_storage.group_outbound_mtx); - session_storage.group_outbound_session_data[key] = data; - session_storage.group_outbound_sessions[key] = std::move(session); + session_storage.group_outbound_session_data[room_id] = data; + session_storage.group_outbound_sessions[room_id] = std::move(session); } } @@ -302,7 +301,7 @@ Cache::saveOutboundOlmSession(const std::string &curve25519, mtx::crypto::OlmSes const auto pickled = pickle<SessionObject>(session.get(), SECRET); auto txn = lmdb::txn::begin(env_); - lmdb::dbi_put(txn, outboundMegolmSessionDb_, lmdb::val(curve25519), lmdb::val(pickled)); + lmdb::dbi_put(txn, outboundOlmSessionDb_, lmdb::val(curve25519), lmdb::val(pickled)); txn.commit(); { @@ -372,8 +371,8 @@ Cache::restoreSessions() unpickle<OutboundSessionObject>(obj.at("session"), SECRET); session_storage.group_outbound_sessions[key] = std::move(session); } catch (const nlohmann::json::exception &e) { - log::db()->warn("failed to parse outbound megolm session data: {}", - e.what()); + log::db()->critical( + "failed to parse outbound megolm session data: {}", e.what()); } } cursor.close();