summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgirlbossceo <june@girlboss.ceo>2023-07-29 19:17:12 +0000
committergirlbossceo <june@girlboss.ceo>2023-07-29 19:17:12 +0000
commite2c914cc11f268bb6212e68e6b71b74255b24b97 (patch)
tree9098735922bb82e379e6cea57491238977ae78ec
parent2b4a6c96eee95c5efe43803d247469fd6d67075f (diff)
downloadconduit-e2c914cc11f268bb6212e68e6b71b74255b24b97.zip
fix: s/ok_or/ok_or_else in relevant places
Signed-off-by: girlbossceo <june@girlboss.ceo>
-rw-r--r--src/api/client_server/room.rs12
-rw-r--r--src/api/client_server/state.rs4
-rw-r--r--src/api/server_server.rs4
-rw-r--r--src/service/rooms/state/mod.rs2
4 files changed, 13 insertions, 9 deletions
diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs
index 5c98028..56bdf03 100644
--- a/src/api/client_server/room.rs
+++ b/src/api/client_server/room.rs
@@ -425,10 +425,14 @@ pub async fn get_room_event_route(
) -> Result<get_room_event::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
- let event = services().rooms.timeline.get_pdu(&body.event_id)?.ok_or({
- warn!("Event not found, event ID: {:?}", &body.event_id);
- Error::BadRequest(ErrorKind::NotFound, "Event not found.")
- })?;
+ let event = services()
+ .rooms
+ .timeline
+ .get_pdu(&body.event_id)?
+ .ok_or_else(|| {
+ warn!("Event not found, event ID: {:?}", &body.event_id);
+ Error::BadRequest(ErrorKind::NotFound, "Event not found.")
+ })?;
if !services().rooms.state_accessor.user_can_see_event(
sender_user,
diff --git a/src/api/client_server/state.rs b/src/api/client_server/state.rs
index 6a37489..d6d3939 100644
--- a/src/api/client_server/state.rs
+++ b/src/api/client_server/state.rs
@@ -130,7 +130,7 @@ pub async fn get_state_events_for_key_route(
.rooms
.state_accessor
.room_state_get(&body.room_id, &body.event_type, &body.state_key)?
- .ok_or({
+ .ok_or_else(|| {
warn!(
"State event {:?} not found in room {:?}",
&body.event_type, &body.room_id
@@ -169,7 +169,7 @@ pub async fn get_state_events_for_empty_key_route(
.rooms
.state_accessor
.room_state_get(&body.room_id, &body.event_type, "")?
- .ok_or({
+ .ok_or_else(|| {
warn!(
"State event {:?} not found in room {:?}",
&body.event_type, &body.room_id
diff --git a/src/api/server_server.rs b/src/api/server_server.rs
index 8c54e92..ca5b69d 100644
--- a/src/api/server_server.rs
+++ b/src/api/server_server.rs
@@ -953,7 +953,7 @@ pub async fn get_event_route(
.rooms
.timeline
.get_pdu_json(&body.event_id)?
- .ok_or({
+ .ok_or_else(|| {
warn!("Event not found, event ID: {:?}", &body.event_id);
Error::BadRequest(ErrorKind::NotFound, "Event not found.")
})?;
@@ -1196,7 +1196,7 @@ pub async fn get_event_authorization_route(
.rooms
.timeline
.get_pdu_json(&body.event_id)?
- .ok_or({
+ .ok_or_else(|| {
warn!("Event not found, event ID: {:?}", &body.event_id);
Error::BadRequest(ErrorKind::NotFound, "Event not found.")
})?;
diff --git a/src/service/rooms/state/mod.rs b/src/service/rooms/state/mod.rs
index 9790695..16e0a04 100644
--- a/src/service/rooms/state/mod.rs
+++ b/src/service/rooms/state/mod.rs
@@ -342,7 +342,7 @@ impl Service {
.transpose()?;
let room_version = create_event_content
.map(|create_event| create_event.room_version)
- .ok_or({
+ .ok_or_else(|| {
warn!("Invalid room version for room {room_id}");
Error::BadDatabase("Invalid room version")
})?;