Return a Result<Option<Message>> for get_draft

The function can fail, so we need to still have an error return as
well as a no-draft return.

Add tests.
This commit is contained in:
Floris Bruynooghe
2019-09-14 00:50:24 +02:00
parent db20ecf985
commit 8a7143b791
3 changed files with 68 additions and 16 deletions

View File

@@ -663,7 +663,7 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
},
);
log_msglist(context, &msglist)?;
if let Ok(draft) = chat::get_draft(context, sel_chat.get_id()) {
if let Some(draft) = chat::get_draft(context, sel_chat.get_id())? {
log_msg(context, "Draft", &draft);
}