Page MenuHomePhabricator

D11169.id.diff
No OneTemporary

D11169.id.diff

diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/MessageToDevice.h b/native/cpp/CommonCpp/DatabaseManagers/entities/MessageToDevice.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/DatabaseManagers/entities/MessageToDevice.h
@@ -0,0 +1,71 @@
+#pragma once
+
+#include <sqlite3.h>
+#include <memory>
+#include <string>
+
+#include "SQLiteDataConverters.h"
+
+namespace comm {
+
+struct MessageToDevice {
+ std::string message_id;
+ std::string device_id;
+ std::string user_id;
+ int64_t timestamp;
+ std::string plaintext;
+ std::string ciphertext;
+
+ static MessageToDevice fromSQLResult(sqlite3_stmt *sqlRow, int idx) {
+ return MessageToDevice{
+ getStringFromSQLRow(sqlRow, idx),
+ getStringFromSQLRow(sqlRow, idx + 1),
+ getStringFromSQLRow(sqlRow, idx + 2),
+ getInt64FromSQLRow(sqlRow, idx + 3),
+ getStringFromSQLRow(sqlRow, idx + 4),
+ getStringFromSQLRow(sqlRow, idx + 5),
+ };
+ }
+
+ int bindToSQL(sqlite3_stmt *sql, int idx) const {
+ bindStringToSQL(message_id, sql, idx);
+ bindStringToSQL(device_id, sql, idx + 1);
+ bindStringToSQL(user_id, sql, idx + 2);
+ bindInt64ToSQL(timestamp, sql, idx + 3);
+ bindStringToSQL(plaintext, sql, idx + 4);
+ return bindStringToSQL(ciphertext, sql, idx + 5);
+ }
+};
+
+struct ClientMessageToDevice {
+ std::string message_id;
+ std::string device_id;
+ std::string user_id;
+ std::string timestamp;
+ std::string plaintext;
+ std::string ciphertext;
+
+ ClientMessageToDevice() = default;
+
+ ClientMessageToDevice(const MessageToDevice &msg) {
+ message_id = msg.message_id;
+ device_id = msg.device_id;
+ user_id = msg.user_id;
+ timestamp = std::to_string(msg.timestamp);
+ plaintext = msg.plaintext;
+ ciphertext = msg.ciphertext;
+ }
+
+ MessageToDevice toMessageToDevice() const {
+ MessageToDevice msg;
+ msg.message_id = message_id;
+ msg.device_id = device_id;
+ msg.user_id = user_id;
+ msg.timestamp = std::stoll(timestamp);
+ msg.plaintext = plaintext;
+ msg.ciphertext = ciphertext;
+ return msg;
+ }
+};
+
+} // namespace comm
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
--- a/web/cpp/SQLiteQueryExecutorBindings.cpp
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -1,4 +1,5 @@
#include "SQLiteQueryExecutor.cpp"
+#include "entities/MessageToDevice.h"
#include "entities/Nullable.h"
#include <emscripten/bind.h>
@@ -96,6 +97,14 @@
.field("targetUserID", &OlmPersistSession::target_user_id)
.field("sessionData", &OlmPersistSession::session_data);
+ value_object<ClientMessageToDevice>("ClientMessageToDevice")
+ .field("messageID", &ClientMessageToDevice::message_id)
+ .field("deviceID", &ClientMessageToDevice::device_id)
+ .field("userID", &ClientMessageToDevice::user_id)
+ .field("timestamp", &ClientMessageToDevice::timestamp)
+ .field("plaintext", &ClientMessageToDevice::plaintext)
+ .field("ciphertext", &ClientMessageToDevice::ciphertext);
+
class_<SQLiteQueryExecutor>("SQLiteQueryExecutor")
.constructor<std::string>()
.function("updateDraft", &SQLiteQueryExecutor::updateDraft)
diff --git a/web/database/_generated/comm_query_executor.wasm b/web/database/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/web/database/types/sqlite-query-executor.js b/web/database/types/sqlite-query-executor.js
--- a/web/database/types/sqlite-query-executor.js
+++ b/web/database/types/sqlite-query-executor.js
@@ -37,6 +37,15 @@
+sessionData: string,
};
+export type ClientMessageToDevice = {
+ +messageID: string,
+ +deviceID: string,
+ +userID: string,
+ +timestamp: string,
+ +plaintext: string,
+ +ciphertext: string,
+};
+
declare export class SQLiteQueryExecutor {
constructor(sqliteFilePath: string): void;

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 7:12 PM (8 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700866
Default Alt Text
D11169.id.diff (3 KB)

Event Timeline