From 89f394ab86d9d991cba953cf810824a9373e10ee Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Mon, 4 Nov 2019 17:00:23 +0100 Subject: [PATCH] create separate function for preparing a blob --- src/chat.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/chat.rs b/src/chat.rs index c806a2a9c..11ae5fee2 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -689,8 +689,7 @@ pub fn msgtype_has_file(msgtype: Viewtype) -> bool { } } -fn prepare_msg_common(context: &Context, chat_id: u32, msg: &mut Message) -> Result { - msg.id = MsgId::new_unset(); +fn prepare_msg_blob(context: &Context, msg: &mut Message) -> Result<(), Error> { if msg.type_0 == Viewtype::Text { // the caller should check if the message text is empty } else if msgtype_has_file(msg.type_0) { @@ -726,7 +725,12 @@ fn prepare_msg_common(context: &Context, chat_id: u32, msg: &mut Message) -> Res } else { bail!("Cannot send messages of type #{}.", msg.type_0); } + Ok(()) +} +fn prepare_msg_common(context: &Context, chat_id: u32, msg: &mut Message) -> Result { + msg.id = MsgId::new_unset(); + prepare_msg_blob(context, msg)?; unarchive(context, chat_id)?; let mut chat = Chat::load_from_db(context, chat_id)?;