mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-30 05:04:29 +02:00
feat: Do not allow suspended users to send typing statuses
This commit is contained in:
parent
1124097bd1
commit
72f8cb3038
1 changed files with 34 additions and 33 deletions
|
@ -26,41 +26,42 @@ pub(crate) async fn create_typing_event_route(
|
||||||
{
|
{
|
||||||
return Err!(Request(Forbidden("You are not in this room.")));
|
return Err!(Request(Forbidden("You are not in this room.")));
|
||||||
}
|
}
|
||||||
|
if !services.users.is_suspended(sender_user).await? {
|
||||||
match body.state {
|
match body.state {
|
||||||
| Typing::Yes(duration) => {
|
| Typing::Yes(duration) => {
|
||||||
let duration = utils::clamp(
|
let duration = utils::clamp(
|
||||||
duration.as_millis().try_into().unwrap_or(u64::MAX),
|
duration.as_millis().try_into().unwrap_or(u64::MAX),
|
||||||
|
services
|
||||||
|
.server
|
||||||
|
.config
|
||||||
|
.typing_client_timeout_min_s
|
||||||
|
.try_mul(1000)?,
|
||||||
|
services
|
||||||
|
.server
|
||||||
|
.config
|
||||||
|
.typing_client_timeout_max_s
|
||||||
|
.try_mul(1000)?,
|
||||||
|
);
|
||||||
services
|
services
|
||||||
.server
|
.rooms
|
||||||
.config
|
.typing
|
||||||
.typing_client_timeout_min_s
|
.typing_add(
|
||||||
.try_mul(1000)?,
|
sender_user,
|
||||||
|
&body.room_id,
|
||||||
|
utils::millis_since_unix_epoch()
|
||||||
|
.checked_add(duration)
|
||||||
|
.expect("user typing timeout should not get this high"),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
},
|
||||||
|
| _ => {
|
||||||
services
|
services
|
||||||
.server
|
.rooms
|
||||||
.config
|
.typing
|
||||||
.typing_client_timeout_max_s
|
.typing_remove(sender_user, &body.room_id)
|
||||||
.try_mul(1000)?,
|
.await?;
|
||||||
);
|
},
|
||||||
services
|
}
|
||||||
.rooms
|
|
||||||
.typing
|
|
||||||
.typing_add(
|
|
||||||
sender_user,
|
|
||||||
&body.room_id,
|
|
||||||
utils::millis_since_unix_epoch()
|
|
||||||
.checked_add(duration)
|
|
||||||
.expect("user typing timeout should not get this high"),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
},
|
|
||||||
| _ => {
|
|
||||||
services
|
|
||||||
.rooms
|
|
||||||
.typing
|
|
||||||
.typing_remove(sender_user, &body.room_id)
|
|
||||||
.await?;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ping presence
|
// ping presence
|
||||||
|
|
Loading…
Add table
Reference in a new issue