fix: some compile time errors

Only 174 errors left!
This commit is contained in:
Timo Kösters 2022-09-06 23:15:09 +02:00 committed by Nyaaori
parent 82e7f57b38
commit 057f8364cc
No known key found for this signature in database
GPG key ID: E7819C3ED4D1F82E
118 changed files with 2139 additions and 2433 deletions

View file

@ -1,18 +1,17 @@
use crate::{database::DatabaseGuard, utils, Error, Result, Ruma};
use crate::{utils, Error, Result, Ruma, services};
use ruma::api::client::{error::ErrorKind, typing::create_typing_event};
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
///
/// Sets the typing state of the sender user.
pub async fn create_typing_event_route(
db: DatabaseGuard,
body: Ruma<create_typing_event::v3::IncomingRequest>,
) -> Result<create_typing_event::v3::Response> {
use create_typing_event::v3::Typing;
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
if !db.rooms.is_joined(sender_user, &body.room_id)? {
if !services().rooms.is_joined(sender_user, &body.room_id)? {
return Err(Error::BadRequest(
ErrorKind::Forbidden,
"You are not in this room.",
@ -20,16 +19,15 @@ pub async fn create_typing_event_route(
}
if let Typing::Yes(duration) = body.state {
db.rooms.edus.typing_add(
services().rooms.edus.typing_add(
sender_user,
&body.room_id,
duration.as_millis() as u64 + utils::millis_since_unix_epoch(),
&db.globals,
)?;
} else {
db.rooms
services().rooms
.edus
.typing_remove(sender_user, &body.room_id, &db.globals)?;
.typing_remove(sender_user, &body.room_id)?;
}
Ok(create_typing_event::v3::Response {})