mirror of
https://github.com/chatmail/core.git
synced 2026-04-18 05:56:31 +03:00
feat: lookup_key_contact_by_address(): Allow looking up ContactId::SELF without chat id
This doesn't fix anything currently, but let's allow such lookups to avoid future bugs.
This commit is contained in:
@@ -3819,6 +3819,9 @@ async fn lookup_key_contact_by_address(
|
|||||||
chat_id: Option<ChatId>,
|
chat_id: Option<ChatId>,
|
||||||
) -> Result<Option<ContactId>> {
|
) -> Result<Option<ContactId>> {
|
||||||
if context.is_self_addr(addr).await? {
|
if context.is_self_addr(addr).await? {
|
||||||
|
if chat_id.is_none() {
|
||||||
|
return Ok(Some(ContactId::SELF));
|
||||||
|
}
|
||||||
let is_self_in_chat = context
|
let is_self_in_chat = context
|
||||||
.sql
|
.sql
|
||||||
.exists(
|
.exists(
|
||||||
|
|||||||
@@ -5436,3 +5436,15 @@ async fn test_small_unencrypted_group() -> Result<()> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
|
async fn test_lookup_key_contact_by_address_self() -> Result<()> {
|
||||||
|
let mut tcm = TestContextManager::new();
|
||||||
|
let t = &tcm.alice().await;
|
||||||
|
let addr = &t.get_config(Config::Addr).await?.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
lookup_key_contact_by_address(t, addr, None).await?,
|
||||||
|
Some(ContactId::SELF)
|
||||||
|
);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user