mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
make it more idiomatic:
rename `ContactObject::from_dc_contact -> `ContactObject::try_from_dc_contact`
This commit is contained in:
@@ -370,7 +370,7 @@ impl CommandApi {
|
|||||||
let ctx = self.get_context(account_id).await?;
|
let ctx = self.get_context(account_id).await?;
|
||||||
let contact_id = ContactId::new(contact_id);
|
let contact_id = ContactId::new(contact_id);
|
||||||
|
|
||||||
ContactObject::from_dc_contact(
|
ContactObject::try_from_dc_contact(
|
||||||
&ctx,
|
&ctx,
|
||||||
deltachat::contact::Contact::get_by_id(&ctx, contact_id).await?,
|
deltachat::contact::Contact::get_by_id(&ctx, contact_id).await?,
|
||||||
)
|
)
|
||||||
@@ -425,7 +425,7 @@ impl CommandApi {
|
|||||||
let mut contacts: Vec<ContactObject> = Vec::with_capacity(blocked_ids.len());
|
let mut contacts: Vec<ContactObject> = Vec::with_capacity(blocked_ids.len());
|
||||||
for id in blocked_ids {
|
for id in blocked_ids {
|
||||||
contacts.push(
|
contacts.push(
|
||||||
ContactObject::from_dc_contact(
|
ContactObject::try_from_dc_contact(
|
||||||
&ctx,
|
&ctx,
|
||||||
deltachat::contact::Contact::get_by_id(&ctx, id).await?,
|
deltachat::contact::Contact::get_by_id(&ctx, id).await?,
|
||||||
)
|
)
|
||||||
@@ -459,7 +459,7 @@ impl CommandApi {
|
|||||||
let mut contacts: Vec<ContactObject> = Vec::with_capacity(contact_ids.len());
|
let mut contacts: Vec<ContactObject> = Vec::with_capacity(contact_ids.len());
|
||||||
for id in contact_ids {
|
for id in contact_ids {
|
||||||
contacts.push(
|
contacts.push(
|
||||||
ContactObject::from_dc_contact(
|
ContactObject::try_from_dc_contact(
|
||||||
&ctx,
|
&ctx,
|
||||||
deltachat::contact::Contact::get_by_id(&ctx, id).await?,
|
deltachat::contact::Contact::get_by_id(&ctx, id).await?,
|
||||||
)
|
)
|
||||||
@@ -480,7 +480,7 @@ impl CommandApi {
|
|||||||
for id in ids {
|
for id in ids {
|
||||||
contacts.insert(
|
contacts.insert(
|
||||||
id,
|
id,
|
||||||
ContactObject::from_dc_contact(
|
ContactObject::try_from_dc_contact(
|
||||||
&ctx,
|
&ctx,
|
||||||
deltachat::contact::Contact::get_by_id(&ctx, ContactId::new(id)).await?,
|
deltachat::contact::Contact::get_by_id(&ctx, ContactId::new(id)).await?,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ impl FullChat {
|
|||||||
|
|
||||||
for contact_id in &contact_ids {
|
for contact_id in &contact_ids {
|
||||||
contacts.push(
|
contacts.push(
|
||||||
ContactObject::from_dc_contact(
|
ContactObject::try_from_dc_contact(
|
||||||
context,
|
context,
|
||||||
Contact::load_from_db(context, *contact_id).await?,
|
Contact::load_from_db(context, *contact_id).await?,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub struct ContactObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ContactObject {
|
impl ContactObject {
|
||||||
pub async fn from_dc_contact(
|
pub async fn try_from_dc_contact(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
contact: deltachat::contact::Contact,
|
contact: deltachat::contact::Contact,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ impl MessageObject {
|
|||||||
.map(|m| m.get_id().to_u32());
|
.map(|m| m.get_id().to_u32());
|
||||||
|
|
||||||
let sender_contact = Contact::load_from_db(context, message.get_from_id()).await?;
|
let sender_contact = Contact::load_from_db(context, message.get_from_id()).await?;
|
||||||
let sender = ContactObject::from_dc_contact(context, sender_contact).await?;
|
let sender = ContactObject::try_from_dc_contact(context, sender_contact).await?;
|
||||||
let file_bytes = message.get_filebytes(context).await;
|
let file_bytes = message.get_filebytes(context).await;
|
||||||
let override_sender_name = message.get_override_sender_name();
|
let override_sender_name = message.get_override_sender_name();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user