Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3367913
D12737.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D12737.diff
View Options
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -168,6 +168,8 @@
virtual std::vector<InboundP2PMessage> getAllInboundP2PMessage() const = 0;
virtual void
removeInboundP2PMessages(const std::vector<std::string> &ids) const = 0;
+ virtual std::vector<MessageEntity>
+ getRelatedMessages(const std::string &messageID) const = 0;
#ifdef EMSCRIPTEN
virtual std::vector<WebThread> getAllThreadsWeb() const = 0;
@@ -175,6 +177,8 @@
virtual std::vector<MessageWithMedias> getAllMessagesWeb() const = 0;
virtual void replaceMessageWeb(const WebMessage &message) const = 0;
virtual NullableString getOlmPersistAccountDataWeb(int accountID) const = 0;
+ virtual std::vector<MessageWithMedias>
+ getRelatedMessagesWeb(const std::string &messageID) const = 0;
#else
virtual void createMainCompaction(std::string backupID) const = 0;
virtual void captureBackupLogs() const = 0;
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -181,6 +181,8 @@
std::vector<InboundP2PMessage> getAllInboundP2PMessage() const override;
void
removeInboundP2PMessages(const std::vector<std::string> &ids) const override;
+ std::vector<MessageEntity>
+ getRelatedMessages(const std::string &messageID) const override;
#ifdef EMSCRIPTEN
std::vector<WebThread> getAllThreadsWeb() const override;
@@ -188,6 +190,8 @@
std::vector<MessageWithMedias> getAllMessagesWeb() const override;
void replaceMessageWeb(const WebMessage &message) const override;
NullableString getOlmPersistAccountDataWeb(int accountID) const override;
+ std::vector<MessageWithMedias>
+ getRelatedMessagesWeb(const std::string &messageID) const override;
#else
static void clearSensitiveData();
static void initialize(std::string &databasePath);
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
@@ -2418,6 +2418,24 @@
SQLiteQueryExecutor::getConnection(), removeMessagesSQLStream.str(), ids);
}
+std::vector<MessageEntity>
+SQLiteQueryExecutor::getRelatedMessages(const std::string &messageID) const {
+ static std::string getMessageSQL =
+ "SELECT * "
+ "FROM messages "
+ "LEFT JOIN media "
+ " ON messages.id = media.container "
+ "WHERE messages.id = ? OR messages.target_message = ? "
+ "ORDER BY messages.time DESC";
+ comm::SQLiteStatementWrapper preparedSQL(
+ SQLiteQueryExecutor::getConnection(),
+ getMessageSQL,
+ "Failed to get latest message edit");
+ bindStringToSQL(messageID.c_str(), preparedSQL, 1);
+ bindStringToSQL(messageID.c_str(), preparedSQL, 2);
+ return this->processMessagesResults(preparedSQL);
+}
+
#ifdef EMSCRIPTEN
std::vector<WebThread> SQLiteQueryExecutor::getAllThreadsWeb() const {
auto threads = this->getAllThreads();
@@ -2437,9 +2455,9 @@
auto allMessages = this->getAllMessages();
std::vector<MessageWithMedias> allMessageWithMedias;
- for (auto &messageWitMedia : allMessages) {
+ for (auto &messageWithMedia : allMessages) {
allMessageWithMedias.push_back(
- {std::move(messageWitMedia.first), messageWitMedia.second});
+ {std::move(messageWithMedia.first), messageWithMedia.second});
}
return allMessageWithMedias;
@@ -2458,6 +2476,19 @@
}
return std::make_unique<std::string>(accountData.value());
}
+
+std::vector<MessageWithMedias>
+SQLiteQueryExecutor::getRelatedMessagesWeb(const std::string &messageID) const {
+ auto relatedMessages = this->getRelatedMessages(messageID);
+
+ std::vector<MessageWithMedias> relatedMessagesWithMedias;
+ for (auto &messageWithMedia : relatedMessages) {
+ relatedMessagesWithMedias.push_back(
+ {std::move(messageWithMedia.first), messageWithMedia.second});
+ }
+
+ return relatedMessagesWithMedias;
+}
#else
void SQLiteQueryExecutor::clearSensitiveData() {
SQLiteQueryExecutor::closeConnection();
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
--- a/web/cpp/SQLiteQueryExecutorBindings.cpp
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -310,7 +310,10 @@
&SQLiteQueryExecutor::getAllInboundP2PMessage)
.function(
"removeInboundP2PMessages",
- &SQLiteQueryExecutor::removeInboundP2PMessages);
+ &SQLiteQueryExecutor::removeInboundP2PMessages)
+ .function(
+ "getRelatedMessagesWeb",
+ &SQLiteQueryExecutor::getRelatedMessagesWeb);
}
} // namespace comm
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
diff --git a/web/shared-worker/types/sqlite-query-executor.js b/web/shared-worker/types/sqlite-query-executor.js
--- a/web/shared-worker/types/sqlite-query-executor.js
+++ b/web/shared-worker/types/sqlite-query-executor.js
@@ -48,6 +48,11 @@
+version: number,
};
+type MessageEntity = {
+ +message: WebMessage,
+ +medias: $ReadOnlyArray<Media>,
+};
+
declare export class SQLiteQueryExecutor {
constructor(sqliteFilePath: string): void;
@@ -57,10 +62,7 @@
removeAllDrafts(): void;
removeDrafts(ids: $ReadOnlyArray<string>): void;
- getAllMessagesWeb(): $ReadOnlyArray<{
- +message: WebMessage,
- +medias: $ReadOnlyArray<Media>,
- }>;
+ getAllMessagesWeb(): $ReadOnlyArray<MessageEntity>;
removeAllMessages(): void;
removeMessages(ids: $ReadOnlyArray<string>): void;
removeMessagesForThreads(threadIDs: $ReadOnlyArray<string>): void;
@@ -190,6 +192,8 @@
getAllInboundP2PMessage(): $ReadOnlyArray<InboundP2PMessage>;
removeInboundP2PMessages(ids: $ReadOnlyArray<string>): void;
+ getRelatedMessagesWeb(id: string): $ReadOnlyArray<MessageEntity>;
+
// method is provided to manually signal that a C++ object
// is no longer needed and can be deleted
delete(): void;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 5:09 PM (21 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585556
Default Alt Text
D12737.diff (6 KB)
Attached To
Mode
D12737: [SQLite] Introduce getRelatedMessages
Attached
Detach File
Event Timeline
Log In to Comment