dont allow sending/receiving room invites with ignored users
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
2083c38c76
commit
4413793f7e
2 changed files with 26 additions and 2 deletions
|
@ -364,6 +364,14 @@ pub(crate) async fn invite_user_route(
|
||||||
user_id,
|
user_id,
|
||||||
} = &body.recipient
|
} = &body.recipient
|
||||||
{
|
{
|
||||||
|
if services.users.user_is_ignored(sender_user, user_id).await {
|
||||||
|
return Err!(Request(Forbidden("You cannot invite users you have ignored to rooms.")));
|
||||||
|
} else if services.users.user_is_ignored(user_id, sender_user).await {
|
||||||
|
// silently drop the invite to the recipient if they've been ignored by the
|
||||||
|
// sender, pretend it worked
|
||||||
|
return Ok(invite_user::v3::Response {});
|
||||||
|
}
|
||||||
|
|
||||||
invite_helper(&services, sender_user, user_id, &body.room_id, body.reason.clone(), false).await?;
|
invite_helper(&services, sender_user, user_id, &body.room_id, body.reason.clone(), false).await?;
|
||||||
Ok(invite_user::v3::Response {})
|
Ok(invite_user::v3::Response {})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -267,8 +267,16 @@ pub(crate) async fn create_room_route(
|
||||||
let mut users = BTreeMap::from_iter([(sender_user.clone(), int!(100))]);
|
let mut users = BTreeMap::from_iter([(sender_user.clone(), int!(100))]);
|
||||||
|
|
||||||
if preset == RoomPreset::TrustedPrivateChat {
|
if preset == RoomPreset::TrustedPrivateChat {
|
||||||
for invite_ in &body.invite {
|
for invite in &body.invite {
|
||||||
users.insert(invite_.clone(), int!(100));
|
if services.users.user_is_ignored(sender_user, invite).await {
|
||||||
|
return Err!(Request(Forbidden("You cannot invite users you have ignored to rooms.")));
|
||||||
|
} else if services.users.user_is_ignored(invite, sender_user).await {
|
||||||
|
// silently drop the invite to the recipient if they've been ignored by the
|
||||||
|
// sender, pretend it worked
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
users.insert(invite.clone(), int!(100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,6 +484,14 @@ pub(crate) async fn create_room_route(
|
||||||
// 8. Events implied by invite (and TODO: invite_3pid)
|
// 8. Events implied by invite (and TODO: invite_3pid)
|
||||||
drop(state_lock);
|
drop(state_lock);
|
||||||
for user_id in &body.invite {
|
for user_id in &body.invite {
|
||||||
|
if services.users.user_is_ignored(sender_user, user_id).await {
|
||||||
|
return Err!(Request(Forbidden("You cannot invite users you have ignored to rooms.")));
|
||||||
|
} else if services.users.user_is_ignored(user_id, sender_user).await {
|
||||||
|
// silently drop the invite to the recipient if they've been ignored by the
|
||||||
|
// sender, pretend it worked
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if let Err(e) = invite_helper(&services, sender_user, user_id, &room_id, None, body.is_direct)
|
if let Err(e) = invite_helper(&services, sender_user, user_id, &room_id, None, body.is_direct)
|
||||||
.boxed()
|
.boxed()
|
||||||
.await
|
.await
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue