summary refs log tree commit diff
path: root/src/Cache.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-07-17 02:14:44 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-07-17 02:14:44 +0200
commit3f0aa13cb6f83c8768dc30b1a1872b9696992fa7 (patch)
tree2d0408c5395debf10c0f9b4ea9cdb5216af28f0d /src/Cache.cpp
parentStore megolm session data in separate database (diff)
downloadnheko-3f0aa13cb6f83c8768dc30b1a1872b9696992fa7.tar.xz
Share historical keys
We share all keys with our devices and ones created by us to other
users.
Diffstat (limited to '')
-rw-r--r--src/Cache.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Cache.cpp b/src/Cache.cpp

index 1c156104..7b6a6135 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp
@@ -582,6 +582,25 @@ Cache::getOutboundMegolmSession(const std::string &room_id) } } +std::optional<GroupSessionData> +Cache::getMegolmSessionData(const MegolmSessionIndex &index) +{ + try { + using namespace mtx::crypto; + + auto txn = ro_txn(env_); + + std::string_view value; + if (megolmSessionDataDb_.get(txn, json(index).dump(), value)) { + return nlohmann::json::parse(value).get<GroupSessionData>(); + } + + return std::nullopt; + } catch (std::exception &e) { + nhlog::db()->error("Failed to retrieve Megolm Session Data: {}", e.what()); + return std::nullopt; + } +} // // OLM sessions. // @@ -4622,6 +4641,11 @@ inboundMegolmSessionExists(const MegolmSessionIndex &index) { return instance_->inboundMegolmSessionExists(index); } +std::optional<GroupSessionData> +getMegolmSessionData(const MegolmSessionIndex &index) +{ + return instance_->getMegolmSessionData(index); +} // // Olm Sessions