diff options
Diffstat (limited to 'filamento/src/logic/offline.rs')
-rw-r--r-- | filamento/src/logic/offline.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/filamento/src/logic/offline.rs b/filamento/src/logic/offline.rs index 606b04f..aa84f3d 100644 --- a/filamento/src/logic/offline.rs +++ b/filamento/src/logic/offline.rs @@ -1,6 +1,7 @@ use std::process::id; use chrono::Utc; +use jid::FullJID; use lampada::error::WriteError; use tracing::error; use uuid::Uuid; @@ -19,9 +20,13 @@ use crate::{ }; use super::{ + ClientLogic, local_only::{ - handle_delete_chat, handle_delete_messaage, handle_get_chat, handle_get_chat_and_user, handle_get_chats, handle_get_chats_ordered, handle_get_chats_ordered_with_latest_messages, handle_get_chats_ordered_with_latest_messages_and_users, handle_get_message, handle_get_messages, handle_get_messages_with_users, handle_get_user - }, ClientLogic + handle_delete_chat, handle_delete_messaage, handle_get_chat, handle_get_chat_and_user, + handle_get_chats, handle_get_chats_ordered, handle_get_chats_ordered_with_latest_messages, + handle_get_chats_ordered_with_latest_messages_and_users, handle_get_message, + handle_get_messages, handle_get_messages_with_users, handle_get_user, + }, }; pub async fn handle_offline<Fs: FileStore + Clone>(logic: ClientLogic<Fs>, command: Command<Fs>) { @@ -153,7 +158,7 @@ pub async fn handle_offline_result<Fs: FileStore + Clone>( let message = Message { id, - from: logic.bare_jid.clone(), + from: logic.jid.clone(), // TODO: failure reason delivery: Some(Delivery::Failed), timestamp, @@ -163,11 +168,15 @@ pub async fn handle_offline_result<Fs: FileStore + Clone>( // 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 - logic.bare_jid.clone(), + FullJID { + bare_jid: logic.jid.clone(), + resourcepart: "unsent".to_string(), + }, ) .await { @@ -177,12 +186,12 @@ pub async fn handle_offline_result<Fs: FileStore + Clone>( .await; } - let from = match logic.db().read_user(logic.bare_jid.clone()).await { + let from = match logic.db().read_user(logic.jid.clone()).await { Ok(u) => u, Err(e) => { error!("{}", e); User { - jid: logic.bare_jid.clone(), + jid: logic.jid.clone(), nick: None, avatar: None, } @@ -192,7 +201,7 @@ pub async fn handle_offline_result<Fs: FileStore + Clone>( logic .update_sender() .send(crate::UpdateMessage::Message { - to: jid.as_bare(), + to: jid, message, from, }) |