mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
More context for chat and chatlist errors (#3932)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use anyhow::{anyhow, bail, Result};
|
use anyhow::{anyhow, bail, Context as _, Result};
|
||||||
use deltachat::chat::{self, get_chat_contacts, ChatVisibility};
|
use deltachat::chat::{self, get_chat_contacts, ChatVisibility};
|
||||||
use deltachat::chat::{Chat, ChatId};
|
use deltachat::chat::{Chat, ChatId};
|
||||||
use deltachat::constants::Chattype;
|
use deltachat::constants::Chattype;
|
||||||
@@ -53,7 +53,9 @@ impl FullChat {
|
|||||||
contacts.push(
|
contacts.push(
|
||||||
ContactObject::try_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
|
||||||
|
.context("failed to load contact")?,
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
)
|
)
|
||||||
@@ -73,7 +75,8 @@ impl FullChat {
|
|||||||
let was_seen_recently = if chat.get_type() == Chattype::Single {
|
let was_seen_recently = if chat.get_type() == Chattype::Single {
|
||||||
match contact_ids.get(0) {
|
match contact_ids.get(0) {
|
||||||
Some(contact) => Contact::load_from_db(context, *contact)
|
Some(contact) => Contact::load_from_db(context, *contact)
|
||||||
.await?
|
.await
|
||||||
|
.context("failed to load contact for was_seen_recently")?
|
||||||
.was_seen_recently(),
|
.was_seen_recently(),
|
||||||
None => false,
|
None => false,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use deltachat::chat::{Chat, ChatId};
|
use deltachat::chat::{Chat, ChatId};
|
||||||
use deltachat::chatlist::get_last_message_for_chat;
|
use deltachat::chatlist::get_last_message_for_chat;
|
||||||
use deltachat::constants::*;
|
use deltachat::constants::*;
|
||||||
@@ -64,8 +64,10 @@ pub(crate) async fn get_chat_list_item_by_id(
|
|||||||
|
|
||||||
let last_msgid = get_last_message_for_chat(ctx, chat_id).await?;
|
let last_msgid = get_last_message_for_chat(ctx, chat_id).await?;
|
||||||
|
|
||||||
let chat = Chat::load_from_db(ctx, chat_id).await?;
|
let chat = Chat::load_from_db(ctx, chat_id).await.context("chat")?;
|
||||||
let summary = Chatlist::get_summary2(ctx, chat_id, last_msgid, Some(&chat)).await?;
|
let summary = Chatlist::get_summary2(ctx, chat_id, last_msgid, Some(&chat))
|
||||||
|
.await
|
||||||
|
.context("summary")?;
|
||||||
|
|
||||||
let summary_text1 = summary.prefix.map_or_else(String::new, |s| s.to_string());
|
let summary_text1 = summary.prefix.map_or_else(String::new, |s| s.to_string());
|
||||||
let summary_text2 = summary.text.to_owned();
|
let summary_text2 = summary.text.to_owned();
|
||||||
@@ -93,7 +95,8 @@ pub(crate) async fn get_chat_list_item_by_id(
|
|||||||
let contact = chat_contacts.get(0);
|
let contact = chat_contacts.get(0);
|
||||||
let was_seen_recently = match contact {
|
let was_seen_recently = match contact {
|
||||||
Some(contact) => Contact::load_from_db(ctx, *contact)
|
Some(contact) => Contact::load_from_db(ctx, *contact)
|
||||||
.await?
|
.await
|
||||||
|
.context("contact")?
|
||||||
.was_seen_recently(),
|
.was_seen_recently(),
|
||||||
None => false,
|
None => false,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -311,13 +311,17 @@ impl Chatlist {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let (lastmsg, lastcontact) = if let Some(lastmsg_id) = lastmsg_id {
|
let (lastmsg, lastcontact) = if let Some(lastmsg_id) = lastmsg_id {
|
||||||
let lastmsg = Message::load_from_db(context, lastmsg_id).await?;
|
let lastmsg = Message::load_from_db(context, lastmsg_id)
|
||||||
|
.await
|
||||||
|
.context("loading message failed")?;
|
||||||
if lastmsg.from_id == ContactId::SELF {
|
if lastmsg.from_id == ContactId::SELF {
|
||||||
(Some(lastmsg), None)
|
(Some(lastmsg), None)
|
||||||
} else {
|
} else {
|
||||||
match chat.typ {
|
match chat.typ {
|
||||||
Chattype::Group | Chattype::Broadcast | Chattype::Mailinglist => {
|
Chattype::Group | Chattype::Broadcast | Chattype::Mailinglist => {
|
||||||
let lastcontact = Contact::load_from_db(context, lastmsg.from_id).await?;
|
let lastcontact = Contact::load_from_db(context, lastmsg.from_id)
|
||||||
|
.await
|
||||||
|
.context("loading contact failed")?;
|
||||||
(Some(lastmsg), Some(lastcontact))
|
(Some(lastmsg), Some(lastcontact))
|
||||||
}
|
}
|
||||||
Chattype::Single | Chattype::Undefined => (Some(lastmsg), None),
|
Chattype::Single | Chattype::Undefined => (Some(lastmsg), None),
|
||||||
|
|||||||
Reference in New Issue
Block a user