aboutsummaryrefslogtreecommitdiffstats
path: root/luz/src/chat.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2025-02-18 01:01:17 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2025-02-18 01:01:17 +0000
commit68a7d136705133dc5d3a5d43b9ff4da28eeb6d5b (patch)
treee7ff07721156fa0d4110c2c88b0ad8ef86b54c92 /luz/src/chat.rs
parent0d9e3d27e9b81411b4d4c53e1b1a1c29087d66f3 (diff)
downloadluz-68a7d136705133dc5d3a5d43b9ff4da28eeb6d5b.tar.gz
luz-68a7d136705133dc5d3a5d43b9ff4da28eeb6d5b.tar.bz2
luz-68a7d136705133dc5d3a5d43b9ff4da28eeb6d5b.zip
database work
Diffstat (limited to 'luz/src/chat.rs')
-rw-r--r--luz/src/chat.rs44
1 files changed, 29 insertions, 15 deletions
diff --git a/luz/src/chat.rs b/luz/src/chat.rs
index 24ad709..ff76ce1 100644
--- a/luz/src/chat.rs
+++ b/luz/src/chat.rs
@@ -1,31 +1,45 @@
use jid::JID;
use uuid::Uuid;
-use crate::{roster::Contact, user::User};
-
-#[derive(Debug)]
+#[derive(Debug, sqlx::FromRow)]
pub struct Message {
- id: Uuid,
- // contains full user information
- from: Correspondent,
- body: Body,
+ pub id: Uuid,
+ // does not contain full user information
+ #[sqlx(rename = "from_jid")]
+ pub from: JID,
+ // TODO: originally_from
+ // TODO: message edits
+ // TODO: message timestamp
+ #[sqlx(flatten)]
+ pub body: Body,
}
-#[derive(Debug)]
+// TODO: user migrations
+// pub enum Migrated {
+// Jabber(User),
+// Outside,
+// }
+
+#[derive(Debug, sqlx::FromRow)]
pub struct Body {
// TODO: rich text, other contents, threads
- body: String,
+ pub body: String,
}
+#[derive(sqlx::FromRow)]
pub struct Chat {
- correspondent: Correspondent,
- message_history: Vec<Message>,
+ correspondent: JID,
+ // message history is not stored in chat, retreived separately.
+ // pub message_history: Vec<Message>,
}
-#[derive(Debug)]
-pub enum Correspondent {
- User(User),
- Contact(Contact),
+impl Chat {
+ pub fn new(correspondent: JID) -> Self {
+ Self { correspondent }
+ }
+ pub fn correspondent(&self) -> &JID {
+ &self.correspondent
+ }
}
// TODO: group chats