Support for supabase api

This commit is contained in:
2025-10-12 13:00:35 +02:00
parent 80be4b703d
commit 2561f886c6
7 changed files with 135 additions and 22 deletions
+6 -6
View File
@@ -12,7 +12,7 @@ impl Database {
"CREATE TABLE IF NOT EXISTS chat (
id INTEGER PRIMARY KEY AUTOINCREMENT,
channel_id TEXT NOT NULL,
user_id INTEGER NOT NULL,
user_id TEXT NOT NULL,
contents TEXT NOT NULL,
timestamp INTEGER NOT NULL
)",
@@ -30,7 +30,7 @@ impl Database {
pub fn insert_message(
&self,
channel_id: &str,
user_id: u32,
user_id: &str,
contents: &str,
timestamp: i64,
) -> Result<Message> {
@@ -45,7 +45,7 @@ impl Database {
Ok(Message {
id,
channel_id: channel_id.to_string(),
from: user_id,
from: user_id.to_string(),
contents: contents.to_string(),
timestamp,
})
@@ -73,7 +73,7 @@ impl Database {
}
/// Get a message by its ID
pub fn get_message_by_id(&self, message_id: usize) -> Result<Option<Message>> {
pub fn get_message_by_id(&self, message_id: &str) -> Result<Option<Message>> {
let mut stmt = self.0.prepare(
"SELECT id, channel_id, user_id, contents, timestamp
FROM chat
@@ -95,7 +95,7 @@ impl Database {
return Ok(Some(Message {
id,
channel_id,
from: user_id,
from: user_id.to_string(),
contents,
timestamp,
}));
@@ -116,7 +116,7 @@ impl Database {
Ok(Message {
id: row.get::<_, i64>(0)?,
channel_id: row.get::<_, String>(1)?,
from: row.get::<_, u32>(2)?,
from: row.get::<_, String>(2)?,
contents: row.get::<_, String>(3)?,
timestamp: row.get::<_, i64>(4)?,
})