mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
refactor: add more error context to send_webxdc_status_update()
This is a follow-up to b9fa05c3bb
This commit is contained in:
@@ -477,14 +477,24 @@ impl Context {
|
|||||||
mut status_update: StatusUpdateItem,
|
mut status_update: StatusUpdateItem,
|
||||||
descr: &str,
|
descr: &str,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let mut instance = Message::load_from_db(self, instance_msg_id).await?;
|
let mut instance = Message::load_from_db(self, instance_msg_id)
|
||||||
if instance.viewtype != Viewtype::Webxdc {
|
.await
|
||||||
bail!("send_webxdc_status_update: is no webxdc message");
|
.with_context(|| {
|
||||||
|
format!("Failed to load message {instance_msg_id} from the database")
|
||||||
|
})?;
|
||||||
|
let viewtype = instance.viewtype;
|
||||||
|
if viewtype != Viewtype::Webxdc {
|
||||||
|
bail!("send_webxdc_status_update: message {instance_msg_id} is not a webxdc message, but a {viewtype} message.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let chat = Chat::load_from_db(self, instance.chat_id).await?;
|
let chat_id = instance.chat_id;
|
||||||
if let Some(reason) = chat.why_cant_send(self).await? {
|
let chat = Chat::load_from_db(self, chat_id)
|
||||||
bail!("cannot send to {}: {}", chat.id, reason);
|
.await
|
||||||
|
.with_context(|| format!("Failed to load chat {chat_id} from the database"))?;
|
||||||
|
if let Some(reason) = chat.why_cant_send(self).await.with_context(|| {
|
||||||
|
format!("Failed to check if webxdc update can be sent to chat {chat_id}")
|
||||||
|
})? {
|
||||||
|
bail!("Cannot send to {chat_id}: {reason}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
let send_now = !matches!(
|
let send_now = !matches!(
|
||||||
|
|||||||
Reference in New Issue
Block a user