matrix: Panic when the message-passing channel overflows
This commit is contained in:
parent
50f0bcd3c7
commit
148d4e7e43
@ -32,6 +32,8 @@ use tokio::{
|
|||||||
sync::broadcast
|
sync::broadcast
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use tracing::info;
|
||||||
|
|
||||||
async fn on_stripped_state_member(
|
async fn on_stripped_state_member(
|
||||||
room_member: StrippedRoomMemberEvent,
|
room_member: StrippedRoomMemberEvent,
|
||||||
client: Client,
|
client: Client,
|
||||||
@ -97,18 +99,24 @@ pub async fn login_and_sync<T: Clone>(
|
|||||||
loop {
|
loop {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
Ok(_) = client.sync(settings.clone()) => return Ok(()),
|
Ok(_) = client.sync(settings.clone()) => return Ok(()),
|
||||||
Ok((msg, rooms)) = rx.recv() => {
|
recv = rx.recv() => match recv {
|
||||||
|
Ok((msg, rooms)) => {
|
||||||
|
|
||||||
let msg = &msg.clone();
|
let msg = &msg.clone();
|
||||||
for r in rooms {
|
for r in rooms {
|
||||||
|
info!("Joining room {}", r);
|
||||||
let room = client.join_room_by_id(<&RoomId>::try_from(r.as_str())
|
let room = client.join_room_by_id(<&RoomId>::try_from(r.as_str())
|
||||||
.expect("invalid room ID")
|
.expect("invalid room ID")
|
||||||
).await.expect(format!("Failed to join room {}", r).as_str());
|
).await.expect(format!("Failed to join room {}", r).as_str());
|
||||||
|
|
||||||
|
info!("Posting to room {}", r);
|
||||||
room.send(RoomMessageEventContent::text_html(msg.clone(), msg)).await
|
room.send(RoomMessageEventContent::text_html(msg.clone(), msg)).await
|
||||||
.expect("Failed to send matrix event");
|
.expect("Failed to send matrix event");
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
panic!("Broadcast channel is lagging: {e:?}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user