summary refs log tree commit diff
path: root/src/Cache.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Cache.h')
-rw-r--r--src/Cache.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/Cache.h b/src/Cache.h

index f9a9f9c0..5bdfb113 100644 --- a/src/Cache.h +++ b/src/Cache.h
@@ -235,11 +235,24 @@ struct MegolmSessionIndex std::string session_id; //! The curve25519 public key of the sender. std::string sender_key; - - //! Representation to be used in a hash map. - std::string to_hash() const { return room_id + session_id + sender_key; } }; +inline void +to_json(nlohmann::json &obj, const MegolmSessionIndex &msg) +{ + obj["room_id"] = msg.room_id; + obj["session_id"] = msg.session_id; + obj["sender_key"] = msg.sender_key; +} + +inline void +from_json(const nlohmann::json &obj, MegolmSessionIndex &msg) +{ + msg.room_id = obj.at("room_id"); + msg.session_id = obj.at("session_id"); + msg.sender_key = obj.at("sender_key"); +} + struct OlmSessionStorage { // Megolm sessions @@ -425,13 +438,16 @@ public: bool outboundMegolmSessionExists(const std::string &room_id) noexcept; void updateOutboundMegolmSession(const std::string &room_id, int message_index); + void importSessionKeys(const mtx::crypto::ExportedSessionKeys &keys); + mtx::crypto::ExportedSessionKeys exportSessionKeys(); + // // Inbound Megolm Sessions // void saveInboundMegolmSession(const MegolmSessionIndex &index, mtx::crypto::InboundGroupSessionPtr session); OlmInboundGroupSession *getInboundMegolmSession(const MegolmSessionIndex &index); - bool inboundMegolmSessionExists(const MegolmSessionIndex &index) noexcept; + bool inboundMegolmSessionExists(const MegolmSessionIndex &index); // // Olm Sessions