mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26: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.
|
/// Return true on success, false on database error.
|
||||||
fn do_set_draft(context: &Context, chat_id: u32, msg: &mut Message) -> bool {
|
fn do_set_draft(context: &Context, chat_id: u32, msg: &mut Message) -> bool {
|
||||||
let mut OK_TO_CONTINUE = true;
|
|
||||||
let mut sth_changed = false;
|
let mut sth_changed = false;
|
||||||
|
|
||||||
// save new draft
|
match msg.type_0 {
|
||||||
if msg.type_0 == Viewtype::Text {
|
Viewtype::Unknown => return false,
|
||||||
OK_TO_CONTINUE = msg.text.as_ref().map_or(false, |s| !s.is_empty());
|
Viewtype::Text => if msg.text.as_ref().map_or(false, |s| s.is_empty()) {
|
||||||
} else if msgtype_has_file(msg.type_0) {
|
return false;
|
||||||
|
},
|
||||||
|
_ =>
|
||||||
if let Some(path_filename) = msg.param.get(Param::File) {
|
if let Some(path_filename) = msg.param.get(Param::File) {
|
||||||
let mut path_filename = path_filename.to_string();
|
let mut path_filename = path_filename.to_string();
|
||||||
if dc_msg_is_increation(msg) && !dc_is_blobdir_path(context, &path_filename) {
|
if dc_msg_is_increation(msg) && !dc_is_blobdir_path(context, &path_filename) {
|
||||||
OK_TO_CONTINUE = false;
|
return false;
|
||||||
} else if !dc_make_rel_and_copy(context, &mut path_filename) {
|
}
|
||||||
OK_TO_CONTINUE = false;
|
if !dc_make_rel_and_copy(context, &mut path_filename) {
|
||||||
} else {
|
return false;
|
||||||
|
}
|
||||||
msg.param.set(Param::File, path_filename);
|
msg.param.set(Param::File, path_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
OK_TO_CONTINUE = false;
|
{
|
||||||
}
|
|
||||||
if OK_TO_CONTINUE {
|
|
||||||
if sql::execute(
|
if sql::execute(
|
||||||
context,
|
context,
|
||||||
&context.sql,
|
&context.sql,
|
||||||
|
|||||||
Reference in New Issue
Block a user