mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-07-28 02:38:30 +00:00
Remove it from request handler since there's already the context of the request path, added through TraceLayer.
28 lines
916 B
Rust
28 lines
916 B
Rust
use crate::{database::DatabaseGuard, utils, Result, Ruma};
|
|
use create_typing_event::Typing;
|
|
use ruma::api::client::r0::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::Request<'_>>,
|
|
) -> Result<create_typing_event::Response> {
|
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
|
|
|
if let Typing::Yes(duration) = body.state {
|
|
db.rooms.edus.typing_add(
|
|
sender_user,
|
|
&body.room_id,
|
|
duration.as_millis() as u64 + utils::millis_since_unix_epoch(),
|
|
&db.globals,
|
|
)?;
|
|
} else {
|
|
db.rooms
|
|
.edus
|
|
.typing_remove(sender_user, &body.room_id, &db.globals)?;
|
|
}
|
|
|
|
Ok(create_typing_event::Response {})
|
|
}
|