Skip to content

Commit cb6f887

Browse files
committed
do not error out when sending a webxdc update from a broadcast subscriber
1 parent d9474a6 commit cb6f887

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/webxdc.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use serde_json::Value;
3434
use sha2::{Digest, Sha256};
3535
use tokio::{fs::File, io::BufReader};
3636

37-
use crate::chat::{self, Chat};
37+
use crate::chat::{self, CantSendReason, Chat};
3838
use crate::constants::Chattype;
3939
use crate::contact::ContactId;
4040
use crate::context::Context;
@@ -542,9 +542,18 @@ impl Context {
542542
let chat = Chat::load_from_db(self, chat_id)
543543
.await
544544
.with_context(|| format!("Failed to load chat {chat_id} from the database"))?;
545-
if let Some(reason) = chat.why_cant_send(self).await.with_context(|| {
546-
format!("Failed to check if webxdc update can be sent to chat {chat_id}")
547-
})? {
545+
546+
let skip_fn = |reason: &CantSendReason| match reason {
547+
CantSendReason::InBroadcast => true,
548+
_ => false,
549+
};
550+
if let Some(reason) = chat
551+
.why_cant_send_ex(self, &skip_fn)
552+
.await
553+
.with_context(|| {
554+
format!("Failed to check if webxdc update can be sent to chat {chat_id}")
555+
})?
556+
{
548557
bail!("Cannot send to {chat_id}: {reason}.");
549558
}
550559

0 commit comments

Comments
 (0)