From 0d21d70d4ad7eb995db29495bf948fb26ccce473 Mon Sep 17 00:00:00 2001 From: strawberry Date: Fri, 12 Apr 2024 19:50:30 -0400 Subject: [PATCH] remove two unnecessary matches Signed-off-by: strawberry --- src/api/client_server/context.rs | 28 ++++++++++++++++------------ src/service/sending/appservice.rs | 11 ++++------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/api/client_server/context.rs b/src/api/client_server/context.rs index f7f68a9e..0b012219 100644 --- a/src/api/client_server/context.rs +++ b/src/api/client_server/context.rs @@ -131,18 +131,22 @@ pub async fn get_context_route(body: Ruma) -> Result s, - None => services() - .rooms - .state - .get_room_shortstatehash(&room_id)? - .expect("All rooms have state"), - }; + let shortstatehash = services() + .rooms + .state_accessor + .pdu_shortstatehash( + events_after + .last() + .map_or(&*body.event_id, |(_, e)| &*e.event_id), + )? + .map_or( + services() + .rooms + .state + .get_room_shortstatehash(&room_id)? + .expect("All rooms have state"), + |hash| hash, + ); let state_ids = services() .rooms diff --git a/src/service/sending/appservice.rs b/src/service/sending/appservice.rs index fc7e37fc..20155c5f 100644 --- a/src/service/sending/appservice.rs +++ b/src/service/sending/appservice.rs @@ -50,22 +50,19 @@ where let url = reqwest_request.url().clone(); - let mut response = match services() + let mut response = services() .globals .client .appservice .execute(reqwest_request) .await - { - Ok(r) => r, - Err(e) => { + .map_err(|e| { warn!( "Could not send request to appservice {} at {}: {}", registration.id, destination, e ); - return Err(e.into()); - }, - }; + e + })?; // reqwest::Response -> http::Response conversion let status = response.status();