diff options
author | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-07-17 01:27:37 +0200 |
---|---|---|
committer | Nicolas Werner <nicolas.werner@hotmail.de> | 2021-07-17 01:27:37 +0200 |
commit | 9fadd148715790743cb4e87bfe1854923e59c06b (patch) | |
tree | 2f3db93039106328338bd67eac8666b14b5fdaab /src/CacheCryptoStructs.h | |
parent | Fix replies not reloading after fetching them (diff) | |
download | nheko-9fadd148715790743cb4e87bfe1854923e59c06b.tar.xz |
Store megolm session data in separate database
Diffstat (limited to 'src/CacheCryptoStructs.h')
-rw-r--r-- | src/CacheCryptoStructs.h | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/CacheCryptoStructs.h b/src/CacheCryptoStructs.h index 07ca274e..409c9d67 100644 --- a/src/CacheCryptoStructs.h +++ b/src/CacheCryptoStructs.h @@ -27,40 +27,43 @@ enum Trust Q_ENUM_NS(Trust) } -struct DeviceAndMasterKeys +struct DeviceKeysToMsgIndex { - // map from device id or master key id to message_index - std::map<std::string, uint64_t> devices, master_keys; + // map from device key to message_index + // Using the device id is safe because we check for reuse on device list updates + // Using the device id makes our logic much easier to read. + std::map<std::string, uint64_t> deviceids; }; struct SharedWithUsers { // userid to keys - std::map<std::string, DeviceAndMasterKeys> keys; + std::map<std::string, DeviceKeysToMsgIndex> keys; }; // Extra information associated with an outbound megolm session. -struct OutboundGroupSessionData +struct GroupSessionData { - std::string session_id; - std::string session_key; uint64_t message_index = 0; uint64_t timestamp = 0; + std::string sender_claimed_ed25519_key; + std::vector<std::string> forwarding_curve25519_key_chain; + // who has access to this session. // Rotate, when a user leaves the room and share, when a user gets added. - SharedWithUsers initially, currently; + SharedWithUsers currently; }; void -to_json(nlohmann::json &obj, const OutboundGroupSessionData &msg); +to_json(nlohmann::json &obj, const GroupSessionData &msg); void -from_json(const nlohmann::json &obj, OutboundGroupSessionData &msg); +from_json(const nlohmann::json &obj, GroupSessionData &msg); struct OutboundGroupSessionDataRef { mtx::crypto::OutboundGroupSessionPtr session; - OutboundGroupSessionData data; + GroupSessionData data; }; struct DevicePublicKeys @@ -134,6 +137,8 @@ struct UserKeyCache bool master_key_changed = false; //! Device keys that were already used at least once std::set<std::string> seen_device_keys; + //! Device ids that were already used at least once + std::set<std::string> seen_device_ids; }; void |