Page MenuHomePhabricator

D11582.id38904.diff
No OneTemporary

D11582.id38904.diff

diff --git a/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp b/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp
--- a/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp
+++ b/native/cpp/CommonCpp/CryptoTools/CryptoModule.cpp
@@ -334,7 +334,8 @@
std::unordered_map<std::string, std::shared_ptr<Session>>::iterator it;
for (it = this->sessions.begin(); it != this->sessions.end(); ++it) {
OlmBuffer buffer = it->second->storeAsB64(secretKey);
- persist.sessions.insert(make_pair(it->first, buffer));
+ SessionPersist sessionPersist{buffer, it->second->version};
+ persist.sessions.insert(make_pair(it->first, sessionPersist));
}
return persist;
@@ -357,10 +358,11 @@
std::string{::olm_account_last_error(this->getOlmAccount())}};
}
- std::unordered_map<std::string, OlmBuffer>::iterator it;
+ std::unordered_map<std::string, SessionPersist>::iterator it;
for (it = persist.sessions.begin(); it != persist.sessions.end(); ++it) {
std::unique_ptr<Session> session =
- session->restoreFromB64(secretKey, it->second);
+ session->restoreFromB64(secretKey, it->second.buffer);
+ session->version = it->second.version;
this->sessions.insert(make_pair(it->first, move(session)));
}
}
diff --git a/native/cpp/CommonCpp/CryptoTools/Persist.h b/native/cpp/CommonCpp/CryptoTools/Persist.h
--- a/native/cpp/CommonCpp/CryptoTools/Persist.h
+++ b/native/cpp/CommonCpp/CryptoTools/Persist.h
@@ -8,9 +8,14 @@
namespace comm {
namespace crypto {
+struct SessionPersist {
+ OlmBuffer buffer;
+ int version;
+};
+
struct Persist {
OlmBuffer account;
- std::unordered_map<std::string, OlmBuffer> sessions;
+ std::unordered_map<std::string, SessionPersist> sessions;
bool isEmpty() const {
return (this->account.size() == 0);
diff --git a/native/cpp/CommonCpp/CryptoTools/Session.h b/native/cpp/CommonCpp/CryptoTools/Session.h
--- a/native/cpp/CommonCpp/CryptoTools/Session.h
+++ b/native/cpp/CommonCpp/CryptoTools/Session.h
@@ -14,6 +14,8 @@
OlmBuffer olmSessionBuffer;
public:
+ int version;
+
static std::unique_ptr<Session> createSessionAsInitializer(
OlmAccount *account,
std::uint8_t *ownerIdentityKeys,
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -1974,7 +1974,10 @@
for (auto it = persist.sessions.begin(); it != persist.sessions.end(); it++) {
OlmPersistSession persistSession = {
- it->first, std::string(it->second.begin(), it->second.end())};
+ it->first,
+ std::string(it->second.buffer.begin(), it->second.buffer.end()),
+ it->second.version};
+
this->storeOlmPersistSession(persistSession);
}
}
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -469,8 +469,10 @@
crypto::OlmBuffer sessionDataBuffer(
sessionsDataItem.session_data.begin(),
sessionsDataItem.session_data.end());
+ crypto::SessionPersist sessionPersist{
+ sessionDataBuffer, sessionsDataItem.version};
contentPersist.sessions.insert(std::make_pair(
- sessionsDataItem.target_device_id, sessionDataBuffer));
+ sessionsDataItem.target_device_id, sessionPersist));
}
}
diff --git a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
--- a/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
+++ b/native/cpp/CommonCpp/Notifications/BackgroundDataStorage/NotificationsCryptoModule.cpp
@@ -64,7 +64,7 @@
std::string accountString = persistJSON["account"].asString();
crypto::OlmBuffer account =
std::vector<uint8_t>(accountString.begin(), accountString.end());
- std::unordered_map<std::string, crypto::OlmBuffer> sessions;
+ std::unordered_map<std::string, crypto::SessionPersist> sessions;
if (persistJSON["sessions"].isNull()) {
return std::make_unique<crypto::CryptoModule>(
@@ -75,8 +75,8 @@
for (auto &sessionKeyValuePair : persistJSON["sessions"].items()) {
std::string targetUserID = sessionKeyValuePair.first.asString();
std::string sessionData = sessionKeyValuePair.second.asString();
- sessions[targetUserID] =
- std::vector<uint8_t>(sessionData.begin(), sessionData.end());
+ sessions[targetUserID] = {
+ std::vector<uint8_t>(sessionData.begin(), sessionData.end()), 1};
}
return std::make_unique<crypto::CryptoModule>(
notificationsCryptoAccountID,
@@ -93,7 +93,7 @@
folly::dynamic sessions = folly::dynamic::object;
for (auto &sessionKeyValuePair : persist.sessions) {
std::string targetUserID = sessionKeyValuePair.first;
- crypto::OlmBuffer sessionData = sessionKeyValuePair.second;
+ crypto::OlmBuffer sessionData = sessionKeyValuePair.second.buffer;
sessions[targetUserID] =
std::string(sessionData.begin(), sessionData.end());
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 7:38 PM (17 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605920
Default Alt Text
D11582.id38904.diff (5 KB)

Event Timeline