mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
Replace some ContactId::new() calls with constants
This commit is contained in:
@@ -3904,7 +3904,6 @@ mod tests {
|
|||||||
async fn test_self_talk() -> Result<()> {
|
async fn test_self_talk() -> Result<()> {
|
||||||
let t = TestContext::new_alice().await;
|
let t = TestContext::new_alice().await;
|
||||||
let chat = &t.get_self_chat().await;
|
let chat = &t.get_self_chat().await;
|
||||||
assert_eq!(ContactId::SELF, ContactId::new(1));
|
|
||||||
assert!(!chat.id.is_special());
|
assert!(!chat.id.is_special());
|
||||||
assert!(chat.is_self_talk());
|
assert!(chat.is_self_talk());
|
||||||
assert!(chat.visibility == ChatVisibility::Normal);
|
assert!(chat.visibility == ChatVisibility::Normal);
|
||||||
@@ -4321,7 +4320,7 @@ mod tests {
|
|||||||
let contact1 = Contact::create(&context.ctx, "bob", "bob@mail.de")
|
let contact1 = Contact::create(&context.ctx, "bob", "bob@mail.de")
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_ne!(contact1, ContactId::new(0));
|
assert_ne!(contact1, ContactId::UNDEFINED);
|
||||||
|
|
||||||
let chat_id = ChatId::create_for_contact(&context.ctx, contact1)
|
let chat_id = ChatId::create_for_contact(&context.ctx, contact1)
|
||||||
.await
|
.await
|
||||||
@@ -4526,7 +4525,7 @@ mod tests {
|
|||||||
|
|
||||||
// create contact, then unblocked chat
|
// create contact, then unblocked chat
|
||||||
let contact_id = Contact::create(&ctx, "", "bob@foo.de").await.unwrap();
|
let contact_id = Contact::create(&ctx, "", "bob@foo.de").await.unwrap();
|
||||||
assert_ne!(contact_id, ContactId::new(0));
|
assert_ne!(contact_id, ContactId::UNDEFINED);
|
||||||
let found = ChatId::lookup_by_contact(&ctx, contact_id).await.unwrap();
|
let found = ChatId::lookup_by_contact(&ctx, contact_id).await.unwrap();
|
||||||
assert!(found.is_none());
|
assert!(found.is_none());
|
||||||
|
|
||||||
|
|||||||
@@ -1542,7 +1542,7 @@ mod tests {
|
|||||||
Origin::IncomingReplyTo,
|
Origin::IncomingReplyTo,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
assert_ne!(id, ContactId::new(0));
|
assert_ne!(id, ContactId::UNDEFINED);
|
||||||
|
|
||||||
let contact = Contact::load_from_db(&context.ctx, id).await.unwrap();
|
let contact = Contact::load_from_db(&context.ctx, id).await.unwrap();
|
||||||
assert_eq!(contact.get_name(), "");
|
assert_eq!(contact.get_name(), "");
|
||||||
@@ -1697,7 +1697,6 @@ mod tests {
|
|||||||
|
|
||||||
// check SELF
|
// check SELF
|
||||||
let contact = Contact::load_from_db(&t, ContactId::SELF).await.unwrap();
|
let contact = Contact::load_from_db(&t, ContactId::SELF).await.unwrap();
|
||||||
assert_eq!(ContactId::SELF, ContactId::new(1));
|
|
||||||
assert_eq!(contact.get_name(), stock_str::self_msg(&t).await);
|
assert_eq!(contact.get_name(), stock_str::self_msg(&t).await);
|
||||||
assert_eq!(contact.get_addr(), ""); // we're not configured
|
assert_eq!(contact.get_addr(), ""); // we're not configured
|
||||||
assert!(!contact.is_blocked());
|
assert!(!contact.is_blocked());
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ pub(crate) async fn dc_receive_imf_inner(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(avatar_action) = &mime_parser.user_avatar {
|
if let Some(avatar_action) = &mime_parser.user_avatar {
|
||||||
if from_id != ContactId::new(0)
|
if from_id != ContactId::UNDEFINED
|
||||||
&& context
|
&& context
|
||||||
.update_contacts_timestamp(from_id, Param::AvatarTimestamp, sent_timestamp)
|
.update_contacts_timestamp(from_id, Param::AvatarTimestamp, sent_timestamp)
|
||||||
.await?
|
.await?
|
||||||
@@ -305,7 +305,7 @@ pub(crate) async fn dc_receive_imf_inner(
|
|||||||
// Ignore MDNs though, as they never contain the signature even if user has set it.
|
// Ignore MDNs though, as they never contain the signature even if user has set it.
|
||||||
if mime_parser.mdn_reports.is_empty()
|
if mime_parser.mdn_reports.is_empty()
|
||||||
&& is_partial_download.is_none()
|
&& is_partial_download.is_none()
|
||||||
&& from_id != ContactId::new(0)
|
&& from_id != ContactId::UNDEFINED
|
||||||
&& context
|
&& context
|
||||||
.update_contacts_timestamp(from_id, Param::StatusTimestamp, sent_timestamp)
|
.update_contacts_timestamp(from_id, Param::StatusTimestamp, sent_timestamp)
|
||||||
.await?
|
.await?
|
||||||
@@ -417,7 +417,7 @@ pub async fn from_field_to_contact_id(
|
|||||||
"mail has an empty From header: {:?}", from_address_list
|
"mail has an empty From header: {:?}", from_address_list
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok((ContactId::new(0), false, Origin::Unknown))
|
Ok((ContactId::UNDEFINED, false, Origin::Unknown))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -524,7 +524,7 @@ async fn add_parts(
|
|||||||
securejoin_seen = false;
|
securejoin_seen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let test_normal_chat = if from_id == ContactId::new(0) {
|
let test_normal_chat = if from_id == ContactId::UNDEFINED {
|
||||||
Default::default()
|
Default::default()
|
||||||
} else {
|
} else {
|
||||||
ChatIdBlocked::lookup_by_contact(context, from_id).await?
|
ChatIdBlocked::lookup_by_contact(context, from_id).await?
|
||||||
@@ -1144,8 +1144,8 @@ INSERT INTO msgs
|
|||||||
stmt.execute(paramsv![
|
stmt.execute(paramsv![
|
||||||
rfc724_mid,
|
rfc724_mid,
|
||||||
chat_id,
|
chat_id,
|
||||||
if trash { ContactId::new(0) } else { from_id },
|
if trash { ContactId::UNDEFINED } else { from_id },
|
||||||
if trash { ContactId::new(0) } else { to_id },
|
if trash { ContactId::UNDEFINED } else { to_id },
|
||||||
sort_timestamp,
|
sort_timestamp,
|
||||||
sent_timestamp,
|
sent_timestamp,
|
||||||
rcvd_timestamp,
|
rcvd_timestamp,
|
||||||
|
|||||||
@@ -855,8 +855,8 @@ mod tests {
|
|||||||
|
|
||||||
// Check that if there is a message left, the text and metadata are gone
|
// Check that if there is a message left, the text and metadata are gone
|
||||||
if let Ok(msg) = Message::load_from_db(t, msg_id).await {
|
if let Ok(msg) = Message::load_from_db(t, msg_id).await {
|
||||||
assert_eq!(msg.from_id, ContactId::new(0));
|
assert_eq!(msg.from_id, ContactId::UNDEFINED);
|
||||||
assert_eq!(msg.to_id, ContactId::new(0));
|
assert_eq!(msg.to_id, ContactId::UNDEFINED);
|
||||||
assert!(msg.text.is_none_or_empty(), "{:?}", msg.text);
|
assert!(msg.text.is_none_or_empty(), "{:?}", msg.text);
|
||||||
let rawtxt: Option<String> = t
|
let rawtxt: Option<String> = t
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
@@ -711,7 +711,7 @@ mod tests {
|
|||||||
..
|
..
|
||||||
} = qr
|
} = qr
|
||||||
{
|
{
|
||||||
assert_ne!(contact_id, ContactId::new(0));
|
assert_ne!(contact_id, ContactId::UNDEFINED);
|
||||||
assert_eq!(grpname, "test ? test !");
|
assert_eq!(grpname, "test ? test !");
|
||||||
} else {
|
} else {
|
||||||
bail!("Wrong QR code type");
|
bail!("Wrong QR code type");
|
||||||
@@ -729,7 +729,7 @@ mod tests {
|
|||||||
..
|
..
|
||||||
} = qr
|
} = qr
|
||||||
{
|
{
|
||||||
assert_ne!(contact_id, ContactId::new(0));
|
assert_ne!(contact_id, ContactId::UNDEFINED);
|
||||||
assert_eq!(grpname, "test ? test !");
|
assert_eq!(grpname, "test ? test !");
|
||||||
|
|
||||||
let contact = Contact::get_by_id(&ctx.ctx, contact_id).await?;
|
let contact = Contact::get_by_id(&ctx.ctx, contact_id).await?;
|
||||||
@@ -751,7 +751,7 @@ mod tests {
|
|||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
if let Qr::AskVerifyContact { contact_id, .. } = qr {
|
if let Qr::AskVerifyContact { contact_id, .. } = qr {
|
||||||
assert_ne!(contact_id, ContactId::new(0));
|
assert_ne!(contact_id, ContactId::UNDEFINED);
|
||||||
} else {
|
} else {
|
||||||
bail!("Wrong QR code type");
|
bail!("Wrong QR code type");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user