Remove unwraps

This commit is contained in:
Edward Shen 2022-05-09 01:23:35 -07:00
parent 01c2e47e88
commit 59659bdbf8
Signed by: edward
GPG key ID: 19182661E818369F

View file

@ -82,8 +82,7 @@ async fn handle_login(user_id: OwnedUserId, password: &str) -> Result<()> {
device_id: resp.device_id, device_id: resp.device_id,
user_id, user_id,
} }
}) })?
.unwrap()
); );
Ok(()) Ok(())
@ -91,7 +90,7 @@ async fn handle_login(user_id: OwnedUserId, password: &str) -> Result<()> {
async fn handle_run(config_path: PathBuf, crypto_store_path: PathBuf) -> Result<()> { async fn handle_run(config_path: PathBuf, crypto_store_path: PathBuf) -> Result<()> {
let data = std::fs::read_to_string(config_path)?; let data = std::fs::read_to_string(config_path)?;
let config: TomlConfig = toml::from_str(&data).unwrap(); let config: TomlConfig = toml::from_str(&data)?;
let client = Client::builder() let client = Client::builder()
.user_id(&config.session.user_id) .user_id(&config.session.user_id)
@ -270,7 +269,9 @@ async fn uwuify(room: Joined, message: &str) -> Result<()> {
} }
async fn get_previous_message(room: &Joined) -> Result<TextMessageEventContent> { async fn get_previous_message(room: &Joined) -> Result<TextMessageEventContent> {
let last_prev_batch = (**room).last_prev_batch().unwrap(); let last_prev_batch = (**room)
.last_prev_batch()
.context("No previous batch key while trying to find previous message")?;
let request = MessagesOptions::backward(&last_prev_batch); let request = MessagesOptions::backward(&last_prev_batch);
let messages = room.messages(request).await?; let messages = room.messages(request).await?;