Simplify return type of most route handlers
This commit is contained in:
parent
77a87881c9
commit
5fa9190117
38 changed files with 358 additions and 414 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, ConduitResult, Error, Ruma};
|
||||
use crate::{database::DatabaseGuard, pdu::PduBuilder, utils, Error, Result, Ruma};
|
||||
use ruma::{
|
||||
api::client::{
|
||||
error::ErrorKind,
|
||||
|
@ -22,7 +22,7 @@ use std::{
|
|||
pub async fn send_message_event_route(
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<send_message_event::Request<'_>>,
|
||||
) -> ConduitResult<send_message_event::Response> {
|
||||
) -> Result<send_message_event::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device = body.sender_device.as_deref();
|
||||
|
||||
|
@ -62,7 +62,7 @@ pub async fn send_message_event_route(
|
|||
.map_err(|_| Error::bad_database("Invalid txnid bytes in database."))?
|
||||
.try_into()
|
||||
.map_err(|_| Error::bad_database("Invalid event id in txnid data."))?;
|
||||
return Ok(send_message_event::Response { event_id }.into());
|
||||
return Ok(send_message_event::Response { event_id });
|
||||
}
|
||||
|
||||
let mut unsigned = BTreeMap::new();
|
||||
|
@ -94,7 +94,7 @@ pub async fn send_message_event_route(
|
|||
|
||||
db.flush()?;
|
||||
|
||||
Ok(send_message_event::Response::new((*event_id).to_owned()).into())
|
||||
Ok(send_message_event::Response::new((*event_id).to_owned()))
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/messages`
|
||||
|
@ -107,7 +107,7 @@ pub async fn send_message_event_route(
|
|||
pub async fn get_message_events_route(
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_message_events::Request<'_>>,
|
||||
) -> ConduitResult<get_message_events::Response> {
|
||||
) -> Result<get_message_events::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
let sender_device = body.sender_device.as_ref().expect("user is authenticated");
|
||||
|
||||
|
@ -235,5 +235,5 @@ pub async fn get_message_events_route(
|
|||
);
|
||||
}
|
||||
|
||||
Ok(resp.into())
|
||||
Ok(resp)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue