aboutsummaryrefslogtreecommitdiffstats
path: root/filamento/src/logic
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@bunny.garden>2025-08-17 09:15:53 +0100
committerLibravatar cel 🌸 <cel@bunny.garden>2025-08-17 09:15:53 +0100
commite9b472eb0b7e4f832d9df96b674dc8da73b34b94 (patch)
treecb933de9bbf7e0ce0aa090ead2b9d7ad57a20e0e /filamento/src/logic
parent561dc2d6b6bc729ddd936ff7fe175c91b175e8b2 (diff)
downloadluz-e9b472eb0b7e4f832d9df96b674dc8da73b34b94.tar.gz
luz-e9b472eb0b7e4f832d9df96b674dc8da73b34b94.tar.bz2
luz-e9b472eb0b7e4f832d9df96b674dc8da73b34b94.zip
feat: new db schema
Diffstat (limited to 'filamento/src/logic')
-rw-r--r--filamento/src/logic/offline.rs11
-rw-r--r--filamento/src/logic/online.rs5
-rw-r--r--filamento/src/logic/process_stanza.rs30
3 files changed, 15 insertions, 31 deletions
diff --git a/filamento/src/logic/offline.rs b/filamento/src/logic/offline.rs
index aa84f3d..3b0d1c9 100644
--- a/filamento/src/logic/offline.rs
+++ b/filamento/src/logic/offline.rs
@@ -163,21 +163,14 @@ pub async fn handle_offline_result<Fs: FileStore + Clone>(
delivery: Some(Delivery::Failed),
timestamp,
body,
+ source: Vec::new(),
};
// try to store in message history that there is a new message that is sending. if client is quit mid-send then can mark as failed and re-send
// TODO: mark these as potentially failed upon client launch
if let Err(e) = logic
.db()
// TODO: can create message without a resource....
- .create_message_with_user_resource(
- message.clone(),
- jid.clone(),
- // TODO: when message is queued and sent, the from must also be updated with the correct resource
- FullJID {
- bare_jid: logic.jid.clone(),
- resourcepart: "unsent".to_string(),
- },
- )
+ .create_message(message.clone(), jid.clone(), logic.jid.clone())
.await
{
// TODO: should these really be handle_error or just the error macro?
diff --git a/filamento/src/logic/online.rs b/filamento/src/logic/online.rs
index b36f9a9..2368eff 100644
--- a/filamento/src/logic/online.rs
+++ b/filamento/src/logic/online.rs
@@ -520,13 +520,15 @@ pub async fn handle_send_message<Fs: FileStore + Clone>(logic: &ClientLogic<Fs>,
body: body.clone(),
timestamp,
delivery: Some(Delivery::Sending),
+ // TODO: raw stanza logging
+ source: Vec::new(),
};
// try to store in message history that there is a new message that is sending. if client is quit mid-send then can mark as failed and re-send
// TODO: mark these as potentially failed upon client launch
if let Err(e) = logic
.db()
- .create_message_with_user_resource(message.clone(), jid.clone(), connection.jid().clone())
+ .create_message(message.clone(), jid.clone(), connection.jid().to_bare())
.await
{
// TODO: should these really be handle_error or just the error macro?
@@ -586,6 +588,7 @@ pub async fn handle_send_message<Fs: FileStore + Clone>(logic: &ClientLogic<Fs>,
match result {
Ok(_) => {
info!("sent message: {:?}", message_stanza);
+ // TODO: raw stanza
if let Err(e) = logic.db().update_message_delivery(id, Delivery::Written).await {
error!("updating message delivery: {}", e);
}
diff --git a/filamento/src/logic/process_stanza.rs b/filamento/src/logic/process_stanza.rs
index 67b0d3f..5f180b9 100644
--- a/filamento/src/logic/process_stanza.rs
+++ b/filamento/src/logic/process_stanza.rs
@@ -76,31 +76,19 @@ pub async fn recv_message<Fs: FileStore + Clone>(
body: body.body.unwrap_or_default(),
},
delivery: None,
+ // TODO: log raw stanza
+ source: Vec::new(),
};
// TODO: process message type="error"
// save the message to the database
- match logic.db().upsert_chat_and_user(from.to_bare()).await {
- Ok(_) => match from.as_full() {
- Ok(from) => {
- if let Err(e) = logic
- .db()
- .create_message_with_user_resource(
- message.clone(),
- from.to_bare(),
- from.clone(),
- )
- .await
- {
- error!("failed to create message: {}", e);
- }
- }
- Err(e) => error!("failed to create message: {}", e),
- },
- Err(e) => {
- error!("failed to upsert chat and user: {}", e);
- }
- };
+ if let Err(e) = logic
+ .db()
+ .create_message(message.clone(), from.to_bare(), from.to_bare())
+ .await
+ {
+ error!("failed to create message: {}", e);
+ }
let from_user = match logic.db().read_user(from.to_bare()).await {
Ok(u) => u,