Page MenuHomePhabricator

D11582.id39042.diff
No OneTemporary

D11582.id39042.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->getVersion()};
+ 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->setVersion(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
@@ -12,6 +12,7 @@
class Session {
OlmBuffer olmSessionBuffer;
+ int version;
public:
static std::unique_ptr<Session> createSessionAsInitializer(
@@ -31,6 +32,8 @@
restoreFromB64(const std::string &secretKey, OlmBuffer &b64);
OlmSession *getOlmSession();
std::string decrypt(EncryptedData &encryptedData);
+ int getVersion();
+ void setVersion(int newVersion);
};
} // namespace crypto
diff --git a/native/cpp/CommonCpp/CryptoTools/Session.cpp b/native/cpp/CommonCpp/CryptoTools/Session.cpp
--- a/native/cpp/CommonCpp/CryptoTools/Session.cpp
+++ b/native/cpp/CommonCpp/CryptoTools/Session.cpp
@@ -157,5 +157,13 @@
return std::string{(char *)decryptedMessage.data(), decryptedSize};
}
+int Session::getVersion() {
+ return this->version;
+}
+
+void Session::setVersion(int newVersion) {
+ this->version = newVersion;
+}
+
} // namespace crypto
} // namespace comm
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
@@ -1938,7 +1938,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());
}
diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 8:22 PM (17 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605846
Default Alt Text
D11582.id39042.diff (6 KB)

Event Timeline