Private
Public Access
1
0

daemon: implements post office

This commit is contained in:
2025-05-02 14:22:43 -07:00
parent 07b55f8615
commit 2519bc05ad
13 changed files with 234 additions and 48 deletions

View File

@@ -1,8 +1,12 @@
use serde::Serialize;
use super::conversation::ConversationID;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize)]
pub struct OutgoingMessage {
#[serde(skip)]
pub guid: Uuid,
#[serde(rename = "body")]
pub text: String,
@@ -21,6 +25,7 @@ impl OutgoingMessage {
#[derive(Default)]
pub struct OutgoingMessageBuilder {
guid: Option<Uuid>,
text: Option<String>,
conversation_id: Option<ConversationID>,
file_transfer_guids: Option<Vec<String>>,
@@ -31,6 +36,11 @@ impl OutgoingMessageBuilder {
Self::default()
}
pub fn guid(mut self, guid: Uuid) -> Self {
self.guid = Some(guid);
self
}
pub fn text(mut self, text: String) -> Self {
self.text = Some(text);
self
@@ -48,6 +58,7 @@ impl OutgoingMessageBuilder {
pub fn build(self) -> OutgoingMessage {
OutgoingMessage {
guid: self.guid.unwrap_or_else(|| Uuid::new_v4()),
text: self.text.unwrap(),
conversation_id: self.conversation_id.unwrap(),
file_transfer_guids: self.file_transfer_guids.unwrap_or_default(),