diff --git a/src/matrix.rs b/src/matrix.rs index eaca4aa..33e709f 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -128,7 +128,8 @@ pub async fn send(from_mail: &Option, recipient: &Mailbox, plain_conten // Continuously check whether the room has been joined. // Joins can be significantly delayed, depending on the room and the server let mut joined = false; - while !joined { + let mut counter = 0; + while !joined && counter < 10{ match c.get_room(&roomid) { Some(Room::Joined(_)) => joined = true, _ => (), @@ -137,12 +138,14 @@ pub async fn send(from_mail: &Option, recipient: &Mailbox, plain_conten Ok(_) => (), Err(_e) => (), }; - std::thread::sleep(std::time::Duration::from_millis(250)); + std::thread::sleep(std::time::Duration::from_millis(u64::pow(2, counter) * 100)); + counter += 1; } if let Some(Room::Joined(joined)) = c.get_room(&roomid) { joined } else { + println!("Joining room timed out."); continue; } },