mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
Merge pull request #483 from link2xt/dc_msg_exists_safe
Make dc_msg_exists safe and rusty
This commit is contained in:
@@ -156,9 +156,7 @@ impl Job {
|
|||||||
/* if there is a msg-id and it does not exist in the db, cancel sending.
|
/* if there is a msg-id and it does not exist in the db, cancel sending.
|
||||||
this happends if dc_delete_msgs() was called
|
this happends if dc_delete_msgs() was called
|
||||||
before the generated mime was sent out */
|
before the generated mime was sent out */
|
||||||
if 0 != self.foreign_id
|
if 0 != self.foreign_id && !dc_msg_exists(context, self.foreign_id) {
|
||||||
&& 0 == unsafe { dc_msg_exists(context, self.foreign_id) }
|
|
||||||
{
|
|
||||||
warn!(
|
warn!(
|
||||||
context,
|
context,
|
||||||
0, "Message {} for job {} does not exist", self.foreign_id, self.job_id,
|
0, "Message {} for job {} does not exist", self.foreign_id, self.job_id,
|
||||||
|
|||||||
@@ -1032,25 +1032,23 @@ The value is also used for CC:-summaries */
|
|||||||
|
|
||||||
// Context functions to work with messages
|
// Context functions to work with messages
|
||||||
|
|
||||||
pub unsafe fn dc_msg_exists(context: &Context, msg_id: u32) -> libc::c_int {
|
pub fn dc_msg_exists(context: &Context, msg_id: u32) -> bool {
|
||||||
if msg_id <= 9 {
|
if msg_id <= DC_CHAT_ID_LAST_SPECIAL {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let chat_id: Option<i32> = context.sql.query_row_col(
|
let chat_id: Option<u32> = context.sql.query_row_col(
|
||||||
context,
|
context,
|
||||||
"SELECT chat_id FROM msgs WHERE id=?;",
|
"SELECT chat_id FROM msgs WHERE id=?;",
|
||||||
params![msg_id as i32],
|
params![msg_id],
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
|
|
||||||
if let Some(chat_id) = chat_id {
|
if let Some(chat_id) = chat_id {
|
||||||
if chat_id != 3 {
|
chat_id != DC_CHAT_ID_TRASH
|
||||||
return 1;
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_update_msg_move_state(
|
pub fn dc_update_msg_move_state(
|
||||||
|
|||||||
Reference in New Issue
Block a user