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