Log the reason when the message cannot be sent to the chat

This commit is contained in:
link2xt
2022-12-04 16:53:53 +00:00
parent b4f348ccea
commit 7e5becb5e5
3 changed files with 84 additions and 20 deletions

View File

@@ -360,7 +360,9 @@ impl Context {
}
let chat = Chat::load_from_db(self, instance.chat_id).await?;
ensure!(chat.can_send(self).await?, "cannot send to {}", chat.id);
if let Some(reason) = chat.why_cant_send(self).await? {
bail!("cannot send to {}: {}", chat.id, reason);
}
let send_now = !matches!(
instance.state,