remove some unused builder code in daemon::models::message
This commit is contained in:
@@ -64,12 +64,6 @@ pub struct Message {
|
|||||||
pub attachments: Vec<Attachment>,
|
pub attachments: Vec<Attachment>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Message {
|
|
||||||
pub fn builder() -> MessageBuilder {
|
|
||||||
MessageBuilder::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn attachments_from(file_transfer_guids: &Vec<String>, attachment_metadata: &Option<HashMap<String, AttachmentMetadata>>) -> Vec<Attachment> {
|
fn attachments_from(file_transfer_guids: &Vec<String>, attachment_metadata: &Option<HashMap<String, AttachmentMetadata>>) -> Vec<Attachment> {
|
||||||
file_transfer_guids
|
file_transfer_guids
|
||||||
.iter()
|
.iter()
|
||||||
@@ -159,59 +153,3 @@ impl From<&OutgoingMessage> for Message {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct MessageBuilder {
|
|
||||||
id: Option<String>,
|
|
||||||
sender: Option<Participant>,
|
|
||||||
text: Option<String>,
|
|
||||||
date: Option<NaiveDateTime>,
|
|
||||||
attachments: Vec<Attachment>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for MessageBuilder {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::new()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MessageBuilder {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
id: None,
|
|
||||||
sender: None,
|
|
||||||
text: None,
|
|
||||||
date: None,
|
|
||||||
attachments: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn sender(mut self, sender: Participant) -> Self {
|
|
||||||
self.sender = Some(sender);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn text(mut self, text: String) -> Self {
|
|
||||||
self.text = Some(text);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn date(mut self, date: NaiveDateTime) -> Self {
|
|
||||||
self.date = Some(date);
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn attachments(mut self, attachments: Vec<Attachment>) -> Self {
|
|
||||||
self.attachments = attachments;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn build(self) -> Message {
|
|
||||||
Message {
|
|
||||||
id: self.id.unwrap_or_else(|| Uuid::new_v4().to_string()),
|
|
||||||
sender: self.sender.unwrap_or(Participant::Me),
|
|
||||||
text: self.text.unwrap_or_default(),
|
|
||||||
date: self.date.unwrap_or_else(|| chrono::Utc::now().naive_utc()),
|
|
||||||
attachments: self.attachments,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user