fix: don't allow unjoined users to send typing notifications
This commit is contained in:
parent
3573d40027
commit
b6b27b66c8
2 changed files with 24 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::{database::DatabaseGuard, utils, Result, Ruma};
|
||||
use ruma::api::client::typing::create_typing_event;
|
||||
use crate::{database::DatabaseGuard, Error, utils, Result, Ruma};
|
||||
use ruma::api::client::{typing::create_typing_event, error::ErrorKind};
|
||||
|
||||
/// # `PUT /_matrix/client/r0/rooms/{roomId}/typing/{userId}`
|
||||
///
|
||||
|
@ -12,6 +12,13 @@ pub async fn create_typing_event_route(
|
|||
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !db.rooms.is_joined(sender_user, &body.room_id)? {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::Forbidden,
|
||||
"You are not in this room.",
|
||||
));
|
||||
}
|
||||
|
||||
if let Typing::Yes(duration) = body.state {
|
||||
db.rooms.edus.typing_add(
|
||||
sender_user,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue