Page MenuHomePhabricator

D12075.diff
No OneTemporary

D12075.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
@@ -137,8 +137,7 @@
restoreFromBackupLog(const std::vector<std::uint8_t> &backupLog) const = 0;
virtual void addOutboundP2PMessages(
const std::vector<OutboundP2PMessage> &messages) const = 0;
- virtual std::vector<OutboundP2PMessage>
- getAllOutboundP2PMessages(const std::string &deviceID) const = 0;
+ virtual std::vector<OutboundP2PMessage> getAllOutboundP2PMessages() const = 0;
virtual void removeOutboundP2PMessagesOlderThan(
std::string lastConfirmedMessageID,
std::string deviceID) 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
@@ -147,8 +147,7 @@
const std::vector<std::uint8_t> &backupLog) const override;
void addOutboundP2PMessages(
const std::vector<OutboundP2PMessage> &messages) const override;
- std::vector<OutboundP2PMessage>
- getAllOutboundP2PMessages(const std::string &deviceID) const override;
+ std::vector<OutboundP2PMessage> getAllOutboundP2PMessages() const override;
void removeOutboundP2PMessagesOlderThan(
std::string lastConfirmedMessageID,
std::string deviceID) const override;
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
@@ -2116,11 +2116,10 @@
}
}
-std::vector<OutboundP2PMessage> SQLiteQueryExecutor::getAllOutboundP2PMessages(
- const std::string &deviceID) const {
+std::vector<OutboundP2PMessage>
+SQLiteQueryExecutor::getAllOutboundP2PMessages() const {
std::string query =
"SELECT * FROM outbound_p2p_messages "
- "WHERE device_id = ? "
"ORDER BY timestamp;";
SQLiteStatementWrapper preparedSQL(
@@ -2128,8 +2127,6 @@
query,
"Failed to get all messages to device");
- sqlite3_bind_text(preparedSQL, 1, deviceID.c_str(), -1, SQLITE_TRANSIENT);
-
std::vector<OutboundP2PMessage> messages;
for (int stepResult = sqlite3_step(preparedSQL); stepResult == SQLITE_ROW;
stepResult = sqlite3_step(preparedSQL)) {
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
@@ -56,7 +56,7 @@
status: 'encrypted',
};
-const device1MessagesOrdered = [TEST_MSG_3, TEST_MSG_1, TEST_MSG_4];
+const messagesOrdered = [TEST_MSG_3, TEST_MSG_1, TEST_MSG_2, TEST_MSG_4];
describe('Outbound P2P messages queries', () => {
let queryExecutor: ?SQLiteQueryExecutor = null;
@@ -90,22 +90,24 @@
});
it('should return all messages', () => {
- expect(queryExecutor?.getAllOutboundP2PMessages(device1).length).toBe(3);
- expect(queryExecutor?.getAllOutboundP2PMessages(device2).length).toBe(1);
+ expect(queryExecutor?.getAllOutboundP2PMessages().length).toBe(4);
});
it('should return messages in correct order', () => {
- const messages = queryExecutor?.getAllOutboundP2PMessages(device1);
- expect(messages).toStrictEqual(device1MessagesOrdered);
+ const messages = queryExecutor?.getAllOutboundP2PMessages();
+ expect(messages).toStrictEqual(messagesOrdered);
});
- it('should remove when there is only one message', () => {
+ it('should not remove messages for a different deviceID', () => {
queryExecutor?.removeOutboundP2PMessagesOlderThan(
- TEST_MSG_2.messageID,
- TEST_MSG_2.deviceID,
+ TEST_MSG_4.messageID,
+ TEST_MSG_4.deviceID,
);
- expect(queryExecutor?.getAllOutboundP2PMessages(device2).length).toBe(0);
+ expect(queryExecutor?.getAllOutboundP2PMessages().length).toBe(1);
+ expect(queryExecutor?.getAllOutboundP2PMessages()).toStrictEqual([
+ TEST_MSG_2,
+ ]);
});
it('should remove older messages', () => {
@@ -113,16 +115,16 @@
TEST_MSG_1.messageID,
TEST_MSG_1.deviceID,
);
- expect(queryExecutor?.getAllOutboundP2PMessages(device1)).toStrictEqual([
+ expect(queryExecutor?.getAllOutboundP2PMessages()).toStrictEqual([
+ TEST_MSG_2,
TEST_MSG_4,
]);
});
it('should remove all messages for given device', () => {
queryExecutor?.removeAllOutboundP2PMessages(device1);
- expect(queryExecutor?.getAllOutboundP2PMessages(device1).length).toBe(0);
queryExecutor?.removeAllOutboundP2PMessages(device2);
- expect(queryExecutor?.getAllOutboundP2PMessages(device2).length).toBe(0);
+ expect(queryExecutor?.getAllOutboundP2PMessages().length).toBe(0);
});
it('should set ciphertext for given message', () => {
@@ -134,8 +136,8 @@
ciphertext,
);
- const messages = queryExecutor?.getAllOutboundP2PMessages(device1) ?? [];
- expect(messages.length).toBe(3);
+ const messages = queryExecutor?.getAllOutboundP2PMessages() ?? [];
+ expect(messages.length).toBe(4);
expect(
messages.find(msg => msg.messageID === TEST_MSG_4.messageID)?.ciphertext,
).toBe(ciphertext);
@@ -147,8 +149,8 @@
TEST_MSG_4.deviceID,
);
- const messages = queryExecutor?.getAllOutboundP2PMessages(device1) ?? [];
- expect(messages.length).toBe(3);
+ const messages = queryExecutor?.getAllOutboundP2PMessages() ?? [];
+ expect(messages.length).toBe(4);
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
@@ -163,9 +163,7 @@
deviceID: string,
): void;
removeAllOutboundP2PMessages(deviceID: string): void;
- getAllOutboundP2PMessages(
- deviceID: string,
- ): $ReadOnlyArray<OutboundP2PMessage>;
+ getAllOutboundP2PMessages(): $ReadOnlyArray<OutboundP2PMessage>;
setCiphertextForOutboundP2PMessage(
messageID: string,
deviceID: string,

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 11:24 AM (21 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2580433
Default Alt Text
D12075.diff (6 KB)

Event Timeline