Gracefully handle send errors.

This commit is contained in:
James Pace 2025-02-17 19:59:39 -05:00
parent 39c532f09b
commit 1a9331917a
1 changed files with 15 additions and 5 deletions

View File

@ -71,11 +71,20 @@ impl MatrixListener {
let rooms = rooms_clone.read().await.clone();
for room in rooms {
room.send(
matrix_sdk::ruma::events::room::message::RoomMessageEventContent::new(msg.clone()),
)
.await
.context("Failed to send message to room.")?;
let send_response = room
.send(
matrix_sdk::ruma::events::room::message::RoomMessageEventContent::new(
msg.clone(),
),
)
.await;
if send_response.is_err() {
log::error!(
"Error sending to room {}. Error \n: {:?}",
room.room_id(),
send_response
);
}
}
Ok(())
@ -113,6 +122,7 @@ impl MatrixListener {
.await
.context("Failed on initial sync.")?
.next_batch;
self.client.add_event_handler(on_room_message);
// Spawn a task for the rest of the syncs.
let spawn_client = self.client.clone();