1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-12-27 12:14:33 +01:00

Merge branch 'patch-1' into 'next'

fix: s/ok_or/ok_or_else in relevant places

See merge request famedly/conduit!521
This commit is contained in:
Timo Kösters 2023-07-29 19:19:05 +00:00
commit 0453a72890
4 changed files with 13 additions and 9 deletions

View file

@ -425,10 +425,14 @@ pub async fn get_room_event_route(
) -> Result<get_room_event::v3::Response> { ) -> Result<get_room_event::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let event = services().rooms.timeline.get_pdu(&body.event_id)?.ok_or({ let event = services()
warn!("Event not found, event ID: {:?}", &body.event_id); .rooms
Error::BadRequest(ErrorKind::NotFound, "Event not found.") .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( if !services().rooms.state_accessor.user_can_see_event(
sender_user, sender_user,

View file

@ -130,7 +130,7 @@ pub async fn get_state_events_for_key_route(
.rooms .rooms
.state_accessor .state_accessor
.room_state_get(&body.room_id, &body.event_type, &body.state_key)? .room_state_get(&body.room_id, &body.event_type, &body.state_key)?
.ok_or({ .ok_or_else(|| {
warn!( warn!(
"State event {:?} not found in room {:?}", "State event {:?} not found in room {:?}",
&body.event_type, &body.room_id &body.event_type, &body.room_id
@ -169,7 +169,7 @@ pub async fn get_state_events_for_empty_key_route(
.rooms .rooms
.state_accessor .state_accessor
.room_state_get(&body.room_id, &body.event_type, "")? .room_state_get(&body.room_id, &body.event_type, "")?
.ok_or({ .ok_or_else(|| {
warn!( warn!(
"State event {:?} not found in room {:?}", "State event {:?} not found in room {:?}",
&body.event_type, &body.room_id &body.event_type, &body.room_id

View file

@ -953,7 +953,7 @@ pub async fn get_event_route(
.rooms .rooms
.timeline .timeline
.get_pdu_json(&body.event_id)? .get_pdu_json(&body.event_id)?
.ok_or({ .ok_or_else(|| {
warn!("Event not found, event ID: {:?}", &body.event_id); warn!("Event not found, event ID: {:?}", &body.event_id);
Error::BadRequest(ErrorKind::NotFound, "Event not found.") Error::BadRequest(ErrorKind::NotFound, "Event not found.")
})?; })?;
@ -1196,7 +1196,7 @@ pub async fn get_event_authorization_route(
.rooms .rooms
.timeline .timeline
.get_pdu_json(&body.event_id)? .get_pdu_json(&body.event_id)?
.ok_or({ .ok_or_else(|| {
warn!("Event not found, event ID: {:?}", &body.event_id); warn!("Event not found, event ID: {:?}", &body.event_id);
Error::BadRequest(ErrorKind::NotFound, "Event not found.") Error::BadRequest(ErrorKind::NotFound, "Event not found.")
})?; })?;

View file

@ -342,7 +342,7 @@ impl Service {
.transpose()?; .transpose()?;
let room_version = create_event_content let room_version = create_event_content
.map(|create_event| create_event.room_version) .map(|create_event| create_event.room_version)
.ok_or({ .ok_or_else(|| {
warn!("Invalid room version for room {room_id}"); warn!("Invalid room version for room {room_id}");
Error::BadDatabase("Invalid room version") Error::BadDatabase("Invalid room version")
})?; })?;