mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
Move module functions to type methods
This moves the module-level lookup and creation functions to the types, which make the naming more consistent. Now the lookup_* get_* and create_* functions all behave similarly. Peraps even more important the API of the lookup now allows distinguishing failure from not found. This in turn is important to be able to remove reliance on a ChatId with a 0 or "unset" value. The locations where this ChatId(0) is still used is in database queries which should be solved in an independed commit.
This commit is contained in:
@@ -355,7 +355,7 @@ impl TestContext {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let chat_id = chat::create_by_contact_id(self, contact_id).await.unwrap();
|
||||
let chat_id = ChatId::create_for_contact(self, contact_id).await.unwrap();
|
||||
Chat::load_from_db(self, chat_id).await.unwrap()
|
||||
}
|
||||
|
||||
@@ -367,13 +367,13 @@ impl TestContext {
|
||||
let contact = Contact::create(self, name, addr)
|
||||
.await
|
||||
.expect("failed to create contact");
|
||||
let chat_id = chat::create_by_contact_id(self, contact).await.unwrap();
|
||||
let chat_id = ChatId::create_for_contact(self, contact).await.unwrap();
|
||||
Chat::load_from_db(self, chat_id).await.unwrap()
|
||||
}
|
||||
|
||||
/// Retrieves the "self" chat.
|
||||
pub async fn get_self_chat(&self) -> Chat {
|
||||
let chat_id = chat::create_by_contact_id(self, DC_CONTACT_ID_SELF)
|
||||
let chat_id = ChatId::create_for_contact(self, DC_CONTACT_ID_SELF)
|
||||
.await
|
||||
.unwrap();
|
||||
Chat::load_from_db(self, chat_id).await.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user