Page MenuHomePhabricator

D12071.diff
No OneTemporary

D12071.diff

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
@@ -147,6 +147,9 @@
std::string messageID,
std::string deviceID,
std::string ciphertext) const = 0;
+ virtual void markOutboundP2PMessageAsSent(
+ std::string messageID,
+ std::string deviceID) const = 0;
virtual void addInboundP2PMessage(InboundP2PMessage message) const = 0;
virtual std::vector<InboundP2PMessage> getAllInboundP2PMessage() const = 0;
virtual void
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
@@ -156,6 +156,8 @@
std::string messageID,
std::string deviceID,
std::string ciphertext) const override;
+ void markOutboundP2PMessageAsSent(std::string messageID, std::string deviceID)
+ const override;
void addInboundP2PMessage(InboundP2PMessage message) const override;
std::vector<InboundP2PMessage> getAllInboundP2PMessage() const override;
void
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
@@ -2201,6 +2201,25 @@
sqlite3_step(preparedSQL);
}
+void SQLiteQueryExecutor::markOutboundP2PMessageAsSent(
+ std::string messageID,
+ std::string deviceID) const {
+ static std::string query =
+ "UPDATE outbound_p2p_messages "
+ "SET status = 'sent' "
+ "WHERE message_id = ? AND device_id = ?;";
+
+ comm::SQLiteStatementWrapper preparedSQL(
+ SQLiteQueryExecutor::getConnection(),
+ query,
+ "Failed to mark OutboundP2PMessage as sent");
+
+ bindStringToSQL(messageID.c_str(), preparedSQL, 1);
+ bindStringToSQL(deviceID.c_str(), preparedSQL, 2);
+
+ sqlite3_step(preparedSQL);
+}
+
void SQLiteQueryExecutor::addInboundP2PMessage(
InboundP2PMessage message) const {
static std::string addMessage =
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
--- a/web/cpp/SQLiteQueryExecutorBindings.cpp
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -277,6 +277,9 @@
.function(
"setCiphertextForOutboundP2PMessage",
&SQLiteQueryExecutor::setCiphertextForOutboundP2PMessage)
+ .function(
+ "markOutboundP2PMessageAsSent",
+ &SQLiteQueryExecutor::markOutboundP2PMessageAsSent)
.function(
"addInboundP2PMessage", &SQLiteQueryExecutor::addInboundP2PMessage)
.function(
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/queries/outbound-p2p-message-queries.test.js b/web/shared-worker/queries/outbound-p2p-message-queries.test.js
--- a/web/shared-worker/queries/outbound-p2p-message-queries.test.js
+++ b/web/shared-worker/queries/outbound-p2p-message-queries.test.js
@@ -133,4 +133,17 @@
messages.find(msg => msg.messageID === TEST_MSG_4.messageID)?.ciphertext,
).toBe(ciphertext);
});
+
+ it('should mark message status as sent', () => {
+ queryExecutor?.markOutboundP2PMessageAsSent(
+ TEST_MSG_4.messageID,
+ TEST_MSG_4.deviceID,
+ );
+
+ const messages = queryExecutor?.getAllOutboundP2PMessages(device1) ?? [];
+ expect(messages.length).toBe(3);
+ expect(
+ messages.find(msg => msg.messageID === TEST_MSG_4.messageID)?.status,
+ ).toBe('sent');
+ });
});
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
@@ -170,6 +170,7 @@
deviceID: string,
ciphertext: string,
): void;
+ markOutboundP2PMessageAsSent(messageID: string, deviceID: string): void;
addInboundP2PMessage(message: InboundP2PMessage): void;
getAllInboundP2PMessage(): $ReadOnlyArray<InboundP2PMessage>;

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 5:26 PM (10 h, 54 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585581
Default Alt Text
D12071.diff (4 KB)

Event Timeline