mirror of
https://github.com/chatmail/core.git
synced 2026-04-28 02:46:29 +03:00
Avoid ok-to-continue pattern in "do_set_draft" function
Note: I strongly suggest reviewing this commit in side-by-side mode. Note: This commit fails CI due incorrect formatting. It is done deliberately to simplify review process.
This commit is contained in:
26
src/chat.rs
26
src/chat.rs
@@ -871,27 +871,27 @@ fn maybe_delete_draft(context: &Context, chat_id: u32) -> bool {
|
||||
///
|
||||
/// Return true on success, false on database error.
|
||||
fn do_set_draft(context: &Context, chat_id: u32, msg: &mut Message) -> bool {
|
||||
let mut OK_TO_CONTINUE = true;
|
||||
let mut sth_changed = false;
|
||||
|
||||
// save new draft
|
||||
if msg.type_0 == Viewtype::Text {
|
||||
OK_TO_CONTINUE = msg.text.as_ref().map_or(false, |s| !s.is_empty());
|
||||
} else if msgtype_has_file(msg.type_0) {
|
||||
match msg.type_0 {
|
||||
Viewtype::Unknown => return false,
|
||||
Viewtype::Text => if msg.text.as_ref().map_or(false, |s| s.is_empty()) {
|
||||
return false;
|
||||
},
|
||||
_ =>
|
||||
if let Some(path_filename) = msg.param.get(Param::File) {
|
||||
let mut path_filename = path_filename.to_string();
|
||||
if dc_msg_is_increation(msg) && !dc_is_blobdir_path(context, &path_filename) {
|
||||
OK_TO_CONTINUE = false;
|
||||
} else if !dc_make_rel_and_copy(context, &mut path_filename) {
|
||||
OK_TO_CONTINUE = false;
|
||||
} else {
|
||||
msg.param.set(Param::File, path_filename);
|
||||
return false;
|
||||
}
|
||||
if !dc_make_rel_and_copy(context, &mut path_filename) {
|
||||
return false;
|
||||
}
|
||||
msg.param.set(Param::File, path_filename);
|
||||
}
|
||||
} else {
|
||||
OK_TO_CONTINUE = false;
|
||||
}
|
||||
if OK_TO_CONTINUE {
|
||||
|
||||
{
|
||||
if sql::execute(
|
||||
context,
|
||||
&context.sql,
|
||||
|
||||
Reference in New Issue
Block a user