diff options
Diffstat (limited to 'filamento')
-rw-r--r-- | filamento/Cargo.toml | 2 | ||||
-rw-r--r-- | filamento/src/chat.rs | 4 | ||||
-rw-r--r-- | filamento/src/logic/process_stanza.rs | 1 | ||||
-rw-r--r-- | filamento/src/roster.rs | 2 | ||||
-rw-r--r-- | filamento/src/user.rs | 1 |
5 files changed, 9 insertions, 1 deletions
diff --git a/filamento/Cargo.toml b/filamento/Cargo.toml index cc05288..65ebcf4 100644 --- a/filamento/Cargo.toml +++ b/filamento/Cargo.toml @@ -5,6 +5,7 @@ edition = "2024" [features] serde = ["dep:serde", "jid/serde", "uuid/serde", "chrono/serde", "lampada/serde"] +reactive_stores = ["dep:reactive_stores"] [dependencies] futures = "0.3.30" @@ -25,6 +26,7 @@ sha1 = "0.10.6" image = "0.25.6" hex = "0.4.3" serde = { version = "1.0.219", features = ["derive"], optional = true } +reactive_stores = { version = "0.1.8", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tokio = { workspace = true, features = ["sync", "time", "rt", "fs", "io-std"] } diff --git a/filamento/src/chat.rs b/filamento/src/chat.rs index 936613e..bb0793f 100644 --- a/filamento/src/chat.rs +++ b/filamento/src/chat.rs @@ -1,13 +1,14 @@ use chrono::{DateTime, Utc}; use jid::JID; use rusqlite::{ - types::{FromSql, ToSqlOutput, Value}, ToSql, + types::{FromSql, ToSqlOutput, Value}, }; use uuid::Uuid; #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "reactive_stores", derive(reactive_stores::Store))] pub struct Message { pub id: Uuid, // does not contain full user information @@ -78,6 +79,7 @@ pub struct Body { #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "reactive_stores", derive(reactive_stores::Store))] pub struct Chat { pub correspondent: JID, pub have_chatted: bool, diff --git a/filamento/src/logic/process_stanza.rs b/filamento/src/logic/process_stanza.rs index a5d40b2..81c3b1f 100644 --- a/filamento/src/logic/process_stanza.rs +++ b/filamento/src/logic/process_stanza.rs @@ -77,6 +77,7 @@ pub async fn recv_message<Fs: FileStore + Clone>( }, delivery: None, }; + // TODO: process message type="error" // save the message to the database match logic.db().upsert_chat_and_user(&from).await { diff --git a/filamento/src/roster.rs b/filamento/src/roster.rs index 8f77086..284e2b8 100644 --- a/filamento/src/roster.rs +++ b/filamento/src/roster.rs @@ -12,6 +12,7 @@ pub struct ContactUpdate { } #[derive(Debug, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "reactive_stores", derive(reactive_stores::Store))] pub struct Contact { // jid is the id used to reference everything, but not the primary key pub user_jid: JID, @@ -21,6 +22,7 @@ pub struct Contact { // TODO: avatar, nickname /// nickname picked by contact // nickname: Option<String>, + #[cfg_attr(feature = "reactive_stores", store(key: String = |group| group.clone()))] pub groups: HashSet<String>, } diff --git a/filamento/src/user.rs b/filamento/src/user.rs index f19a4ad..f30933c 100644 --- a/filamento/src/user.rs +++ b/filamento/src/user.rs @@ -2,6 +2,7 @@ use jid::JID; #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] +#[cfg_attr(feature = "reactive_stores", derive(reactive_stores::Store))] pub struct User { pub jid: JID, pub nick: Option<String>, |