mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-27 11:54:25 +01:00
fix: s/ok_or/ok_or_else in relevant places
Signed-off-by: girlbossceo <june@girlboss.ceo>
This commit is contained in:
parent
2b4a6c96ee
commit
e2c914cc11
4 changed files with 13 additions and 9 deletions
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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.")
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -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")
|
||||||
})?;
|
})?;
|
||||||
|
|
Loading…
Reference in a new issue