diff --git a/lib/client.ts b/lib/client.ts index 73dc71d..22159b3 100644 --- a/lib/client.ts +++ b/lib/client.ts @@ -52,6 +52,7 @@ interface JsonArray extends Array { } type JsonValue = (null | boolean | number | string | JsonObject | JsonArray); export type Message = { + id: number, peer: string, uuid: string, message: Uint8Array, diff --git a/mutinyd/src/protocol.rs b/mutinyd/src/protocol.rs index 2911a26..e577a7e 100644 --- a/mutinyd/src/protocol.rs +++ b/mutinyd/src/protocol.rs @@ -86,6 +86,7 @@ pub enum ResponseBody { #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct Message { + pub id: usize, pub peer: String, pub uuid: String, #[serde(with = "serde_bytes")] diff --git a/mutinyd/src/store.rs b/mutinyd/src/store.rs index 08dbd7e..6b1da9a 100644 --- a/mutinyd/src/store.rs +++ b/mutinyd/src/store.rs @@ -328,7 +328,7 @@ impl<'a> StoreTransaction<'a> { pub fn read_message(&self, app_id: i64) -> Result> { let mut stmt = self.tx.prepare_cached( - "SELECT peer.peer_id, app.uuid, data + "SELECT message_inbox.id, peer.peer_id, app.uuid, data FROM message_inbox JOIN message_data ON message_data.id = message_id JOIN app ON app.id = from_app_id @@ -339,9 +339,10 @@ impl<'a> StoreTransaction<'a> { )?; stmt.query_row([app_id], |row| { Ok(Message { - peer: row.get::<_, String>(0)?, - uuid: row.get::<_, String>(1)?, - message: row.get::<_, Vec>(2)?, + id: row.get::<_, usize>(0)?, + peer: row.get::<_, String>(1)?, + uuid: row.get::<_, String>(2)?, + message: row.get::<_, Vec>(3)?, }) }).optional() }