From 8e6a02f16c3e542492241f585a91fa0100ea7e33 Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Mon, 5 May 2025 18:40:05 +0100 Subject: feat(filamento): reactive_stores support --- filamento/src/chat.rs | 4 +++- filamento/src/logic/process_stanza.rs | 1 + filamento/src/roster.rs | 2 ++ filamento/src/user.rs | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'filamento/src') 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( }, 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, + #[cfg_attr(feature = "reactive_stores", store(key: String = |group| group.clone()))] pub groups: HashSet, } 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, -- cgit