Newer
Older
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(crate) async fn create_typing_event_route(
State(services): State<crate::State>, body: Ruma<create_typing_event::v3::Request>,
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
.rooms
.state_cache
.is_joined(sender_user, &body.room_id)?
{
return Err(Error::BadRequest(ErrorKind::forbidden(), "You are not in this room."));
duration.as_millis().try_into().unwrap_or(u64::MAX),
.globals
.config
.typing_client_timeout_min_s
.checked_mul(1000)
.unwrap(),
.globals
.config
.typing_client_timeout_max_s
.checked_mul(1000)
.unwrap(),
.typing_add(
sender_user,
&body.room_id,
utils::millis_since_unix_epoch()
.checked_add(duration)
.expect("user typing timeout should not get this high"),
)
.rooms
.typing
.typing_remove(sender_user, &body.room_id)
.await?;