Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3357111
D11169.id37812.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11169.id37812.diff
View Options
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
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 10:29 PM (21 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577485
Default Alt Text
D11169.id37812.diff (3 KB)
Attached To
Mode
D11169: [SQLite] add `MessageToDevice` entity
Attached
Detach File
Event Timeline
Log In to Comment