2025-04-27 12:53:45 -07:00
|
|
|
use tokio::sync::oneshot;
|
2025-04-28 16:00:04 -07:00
|
|
|
use kordophone_db::models::{Conversation, Message};
|
2025-04-27 18:07:58 -07:00
|
|
|
use crate::daemon::settings::Settings;
|
2025-04-27 12:53:45 -07:00
|
|
|
|
2025-04-27 13:40:59 -07:00
|
|
|
pub type Reply<T> = oneshot::Sender<T>;
|
2025-04-27 12:53:45 -07:00
|
|
|
|
2025-04-27 13:40:59 -07:00
|
|
|
#[derive(Debug)]
|
2025-04-27 12:53:45 -07:00
|
|
|
pub enum Event {
|
|
|
|
|
/// Get the version of the daemon.
|
|
|
|
|
GetVersion(Reply<String>),
|
|
|
|
|
|
2025-05-01 20:36:43 -07:00
|
|
|
/// Asynchronous event for syncing the conversation list with the server.
|
|
|
|
|
SyncConversationList(Reply<()>),
|
|
|
|
|
|
2025-04-27 12:53:45 -07:00
|
|
|
/// Asynchronous event for syncing all conversations with the server.
|
|
|
|
|
SyncAllConversations(Reply<()>),
|
|
|
|
|
|
2025-04-28 18:39:52 -07:00
|
|
|
/// Asynchronous event for syncing a single conversation with the server.
|
|
|
|
|
SyncConversation(String, Reply<()>),
|
|
|
|
|
|
2025-04-27 12:53:45 -07:00
|
|
|
/// Returns all known conversations from the database.
|
|
|
|
|
GetAllConversations(Reply<Vec<Conversation>>),
|
2025-04-27 18:07:58 -07:00
|
|
|
|
|
|
|
|
/// Returns all known settings from the database.
|
|
|
|
|
GetAllSettings(Reply<Settings>),
|
|
|
|
|
|
|
|
|
|
/// Update settings in the database.
|
|
|
|
|
UpdateSettings(Settings, Reply<()>),
|
2025-04-28 16:00:04 -07:00
|
|
|
|
|
|
|
|
/// Returns all messages for a conversation from the database.
|
|
|
|
|
/// Parameters:
|
|
|
|
|
/// - conversation_id: The ID of the conversation to get messages for.
|
|
|
|
|
/// - last_message_id: (optional) The ID of the last message to get. If None, all messages are returned.
|
|
|
|
|
GetMessages(String, Option<String>, Reply<Vec<Message>>),
|
2025-05-01 01:08:13 -07:00
|
|
|
|
|
|
|
|
/// Delete all conversations from the database.
|
|
|
|
|
DeleteAllConversations(Reply<()>),
|
2025-04-27 12:53:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|