mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 13:26:28 +03:00
Replace some magic numbers with constants
This commit is contained in:
@@ -879,7 +879,7 @@ pub fn send_text_msg(
|
|||||||
) -> Result<MsgId, Error> {
|
) -> Result<MsgId, Error> {
|
||||||
ensure!(
|
ensure!(
|
||||||
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
||||||
"bad chat_id = {} <= 9",
|
"bad chat_id = {} <= DC_CHAT_ID_LAST_SPECIAL",
|
||||||
chat_id
|
chat_id
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1254,7 +1254,7 @@ pub fn get_next_media(
|
|||||||
pub fn archive(context: &Context, chat_id: u32, archive: bool) -> Result<(), Error> {
|
pub fn archive(context: &Context, chat_id: u32, archive: bool) -> Result<(), Error> {
|
||||||
ensure!(
|
ensure!(
|
||||||
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
||||||
"bad chat_id = {} <= 9",
|
"bad chat_id = {} <= DC_CHAT_ID_LAST_SPECIAL",
|
||||||
chat_id
|
chat_id
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1289,7 +1289,7 @@ pub fn archive(context: &Context, chat_id: u32, archive: bool) -> Result<(), Err
|
|||||||
pub fn delete(context: &Context, chat_id: u32) -> Result<(), Error> {
|
pub fn delete(context: &Context, chat_id: u32) -> Result<(), Error> {
|
||||||
ensure!(
|
ensure!(
|
||||||
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
||||||
"bad chat_id = {} <= 9",
|
"bad chat_id = {} <= DC_CHAT_ID_LAST_SPECIAL",
|
||||||
chat_id
|
chat_id
|
||||||
);
|
);
|
||||||
/* Up to 2017-11-02 deleting a group also implied leaving it, see above why we have changed this. */
|
/* Up to 2017-11-02 deleting a group also implied leaving it, see above why we have changed this. */
|
||||||
@@ -1578,7 +1578,7 @@ pub fn remove_contact_from_chat(
|
|||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
ensure!(
|
ensure!(
|
||||||
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
chat_id > DC_CHAT_ID_LAST_SPECIAL,
|
||||||
"bad chat_id = {} <= 9",
|
"bad chat_id = {} <= DC_CHAT_ID_LAST_SPECIAL",
|
||||||
chat_id
|
chat_id
|
||||||
);
|
);
|
||||||
ensure!(
|
ensure!(
|
||||||
|
|||||||
@@ -876,7 +876,7 @@ impl Contact {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn real_exists_by_id(context: &Context, contact_id: u32) -> bool {
|
pub fn real_exists_by_id(context: &Context, contact_id: u32) -> bool {
|
||||||
if !context.sql.is_open() || contact_id <= 9 {
|
if !context.sql.is_open() || contact_id <= DC_CONTACT_ID_LAST_SPECIAL {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -923,7 +923,7 @@ pub fn addr_normalize(addr: &str) -> &str {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn set_block_contact(context: &Context, contact_id: u32, new_blocking: bool) {
|
fn set_block_contact(context: &Context, contact_id: u32, new_blocking: bool) {
|
||||||
if contact_id <= 9 {
|
if contact_id <= DC_CONTACT_ID_LAST_SPECIAL {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1104,7 +1104,7 @@ pub fn mdn_from_ext(
|
|||||||
rfc724_mid: &str,
|
rfc724_mid: &str,
|
||||||
timestamp_sent: i64,
|
timestamp_sent: i64,
|
||||||
) -> Option<(u32, MsgId)> {
|
) -> Option<(u32, MsgId)> {
|
||||||
if from_id <= 9 || rfc724_mid.is_empty() {
|
if from_id <= DC_MSG_ID_LAST_SPECIAL || rfc724_mid.is_empty() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user