mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 01:16:31 +03:00
fix: let search also return hidden contacts if search value is an email address
This commit is contained in:
@@ -1182,7 +1182,9 @@ VALUES (?, ?, ?, ?, ?, ?)
|
|||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
let flag_add_self = (listflags & constants::DC_GCL_ADD_SELF) != 0;
|
let flag_add_self = (listflags & constants::DC_GCL_ADD_SELF) != 0;
|
||||||
let flag_address = (listflags & constants::DC_GCL_ADDRESS) != 0;
|
let flag_address = (listflags & constants::DC_GCL_ADDRESS) != 0;
|
||||||
let minimal_origin = if context.get_config_bool(Config::Bot).await? {
|
let minimal_origin = if context.get_config_bool(Config::Bot).await?
|
||||||
|
|| query.is_some_and(may_be_valid_addr)
|
||||||
|
{
|
||||||
Origin::Unknown
|
Origin::Unknown
|
||||||
} else {
|
} else {
|
||||||
Origin::IncomingReplyTo
|
Origin::IncomingReplyTo
|
||||||
|
|||||||
@@ -420,12 +420,16 @@ async fn test_delete() -> Result<()> {
|
|||||||
Contact::delete(&alice, contact_id).await?;
|
Contact::delete(&alice, contact_id).await?;
|
||||||
let contact = Contact::get_by_id(&alice, contact_id).await?;
|
let contact = Contact::get_by_id(&alice, contact_id).await?;
|
||||||
assert_eq!(contact.origin, Origin::Hidden);
|
assert_eq!(contact.origin, Origin::Hidden);
|
||||||
|
|
||||||
|
// Hidden contacts are found when searching by email address
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Contact::get_all(&alice, 0, Some("bob@example.net"))
|
Contact::get_all(&alice, 0, Some("bob@example.net"))
|
||||||
.await?
|
.await?
|
||||||
.len(),
|
.len(),
|
||||||
0
|
1
|
||||||
);
|
);
|
||||||
|
// Hidden contacts are not found by a non-address query
|
||||||
|
assert_eq!(Contact::get_all(&alice, 0, Some("bob")).await?.len(), 0);
|
||||||
|
|
||||||
// Delete chat.
|
// Delete chat.
|
||||||
chat.get_id().delete(&alice).await?;
|
chat.get_id().delete(&alice).await?;
|
||||||
@@ -483,7 +487,7 @@ async fn test_delete_and_recreate_contact() -> Result<()> {
|
|||||||
Contact::get_all(&t, 0, Some("bob@example.net"))
|
Contact::get_all(&t, 0, Some("bob@example.net"))
|
||||||
.await?
|
.await?
|
||||||
.len(),
|
.len(),
|
||||||
0
|
1
|
||||||
);
|
);
|
||||||
|
|
||||||
let contact_id3 = t.add_or_lookup_contact_id(&bob).await;
|
let contact_id3 = t.add_or_lookup_contact_id(&bob).await;
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ async fn test_key_contacts_migration_autocrypt() -> Result<()> {
|
|||||||
);
|
);
|
||||||
assert_eq!(pgp_bob.get_verifier_id(&t).await?, None);
|
assert_eq!(pgp_bob.get_verifier_id(&t).await?, None);
|
||||||
|
|
||||||
// Hidden address-contact can't be looked up.
|
// Hidden address-contact can't be looked up by name.
|
||||||
assert!(
|
assert!(
|
||||||
Contact::get_all(&t, constants::DC_GCL_ADDRESS, Some("bob@example.net"))
|
Contact::get_all(&t, constants::DC_GCL_ADDRESS, Some("bob"))
|
||||||
.await?
|
.await?
|
||||||
.is_empty()
|
.is_empty()
|
||||||
);
|
);
|
||||||
@@ -113,12 +113,8 @@ async fn test_key_contacts_migration_email2() -> Result<()> {
|
|||||||
)?)).await?;
|
)?)).await?;
|
||||||
t.sql.run_migrations(&t).await?;
|
t.sql.run_migrations(&t).await?;
|
||||||
|
|
||||||
// Hidden key-contact can't be looked up.
|
// Hidden key-contact can't be looked up by name.
|
||||||
assert!(
|
assert!(Contact::get_all(&t, 0, Some("bob")).await?.is_empty());
|
||||||
Contact::get_all(&t, 0, Some("bob@example.net"))
|
|
||||||
.await?
|
|
||||||
.is_empty()
|
|
||||||
);
|
|
||||||
let pgp_bob = Contact::get_by_id(&t, ContactId::new(11001)).await?;
|
let pgp_bob = Contact::get_by_id(&t, ContactId::new(11001)).await?;
|
||||||
assert_eq!(pgp_bob.is_key_contact(), true);
|
assert_eq!(pgp_bob.is_key_contact(), true);
|
||||||
assert_eq!(pgp_bob.origin, Origin::Hidden);
|
assert_eq!(pgp_bob.origin, Origin::Hidden);
|
||||||
@@ -156,9 +152,9 @@ async fn test_key_contacts_migration_verified() -> Result<()> {
|
|||||||
|
|
||||||
t.sql.run_migrations(&t).await?;
|
t.sql.run_migrations(&t).await?;
|
||||||
|
|
||||||
// Hidden address-contact can't be looked up.
|
// Hidden address-contact can't be looked up by name.
|
||||||
assert!(
|
assert!(
|
||||||
Contact::get_all(&t, constants::DC_GCL_ADDRESS, Some("bob@example.net"))
|
Contact::get_all(&t, constants::DC_GCL_ADDRESS, Some("bob"))
|
||||||
.await?
|
.await?
|
||||||
.is_empty()
|
.is_empty()
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user