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, utils, ConduitResult, Ruma};
|
||||
use crate::{database::DatabaseGuard, utils, Result, Ruma};
|
||||
use ruma::api::client::r0::presence::{get_presence, set_presence};
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -9,7 +9,7 @@ use std::time::Duration;
|
|||
pub async fn set_presence_route(
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<set_presence::Request<'_>>,
|
||||
) -> ConduitResult<set_presence::Response> {
|
||||
) -> Result<set_presence::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
for room_id in db.rooms.rooms_joined(sender_user) {
|
||||
|
@ -39,7 +39,7 @@ pub async fn set_presence_route(
|
|||
|
||||
db.flush()?;
|
||||
|
||||
Ok(set_presence::Response {}.into())
|
||||
Ok(set_presence::Response {})
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/presence/{userId}/status`
|
||||
|
@ -51,7 +51,7 @@ pub async fn set_presence_route(
|
|||
pub async fn get_presence_route(
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<get_presence::Request<'_>>,
|
||||
) -> ConduitResult<get_presence::Response> {
|
||||
) -> Result<get_presence::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let mut presence_event = None;
|
||||
|
@ -82,8 +82,7 @@ pub async fn get_presence_route(
|
|||
.last_active_ago
|
||||
.map(|millis| Duration::from_millis(millis.into())),
|
||||
presence: presence.content.presence,
|
||||
}
|
||||
.into())
|
||||
})
|
||||
} else {
|
||||
todo!();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue