fix: Remove incorrect early returns for ignored users

This commit is contained in:
Ginger committed 2025-09-11 16:21:03 +00:00
1 parent cd92964437
commit dbd908d304
3 files changed
+51 -50

No files matched your search

+20 -18
View File
@@ -77,25 +77,27 @@ pub(crate) async fn invite_user_route(
}
}
match recipient_filter_level {
| FilterLevel::Allow => {
invite_helper(
&services,
sender_user,
recipient_user,
&body.room_id,
body.reason.clone(),
false,
)
.boxed()
.await?;
Ok(invite_user::v3::Response {})
},
| FilterLevel::Ignore => Ok(invite_user::v3::Response {}),
| FilterLevel::Block =>
Err!(Request(InviteBlocked("{recipient_user} has blocked invites from you."))),
// return an error for blocked invites. ignored invites aren't handled here
// since the recipient's membership should still be changed to `invite`.
// they're filtered out in api::client::message::is_ignored_pdu
if matches!(recipient_filter_level, FilterLevel::Block) {
return Err!(Request(InviteBlocked(
"{recipient_user} has blocked invites from you."
)));
}
invite_helper(
&services,
sender_user,
recipient_user,
&body.room_id,
body.reason.clone(),
false,
)
.boxed()
.await?;
Ok(invite_user::v3::Response {})
},
| _ => {
Err!(Request(NotFound("User not found.")))
+18 -15
View File
@@ -115,22 +115,25 @@ pub(crate) async fn create_room_route(
// drop invites if the creator has them blocked
continue;
}
match services
.users
.invite_filter_level(sender_user, recipient_user)
.await
{
| FilterLevel::Allow => {
invitees.insert(recipient_user.clone());
},
| FilterLevel::Ignore => {
continue;
},
| FilterLevel::Block =>
return Err!(Request(InviteBlocked(
"{recipient_user} has blocked invites from you."
))),
// if the recipient of the invite is local and has the sender blocked, error
// out. if the recipient is remote we can't tell yet, and if they're local and
// have the sender _ignored_ their invite will be filtered out in
// api::client::message::is_ignored_pdu
if services.globals.user_is_local(recipient_user)
&& matches!(
services
.users
.invite_filter_level(sender_user, recipient_user)
.await,
FilterLevel::Block
) {
return Err!(Request(InviteBlocked(
"{recipient_user} has blocked invites from you."
)));
}
invitees.insert(recipient_user.clone());
}
let _short_id = services
+13 -17
View File
@@ -122,24 +122,20 @@ pub async fn update_membership(
self.mark_as_joined(user_id, room_id);
},
| MembershipState::Invite => {
match self
.services
.users
.invite_filter_level(sender, user_id)
.await
{
| FilterLevel::Allow => {
self.mark_as_invited(user_id, room_id, last_state, invite_via)
.await;
},
| FilterLevel::Ignore => {
// do nothing
},
| FilterLevel::Block =>
return Err!(Request(InviteBlocked(
"{user_id} has blocked invites from you."
))),
// return an error for blocked invites. ignored invites aren't handled here
// since the recipient's membership should still be changed to `invite`.
// they're filtered out in api::client::message::is_ignored_pdu
if matches!(
self.services
.users
.invite_filter_level(sender, user_id)
.await,
FilterLevel::Block
) {
return Err!(Request(InviteBlocked("{user_id} has blocked invites from you.")));
}
self.mark_as_invited(user_id, room_id, last_state, invite_via)
.await;
},
| MembershipState::Leave | MembershipState::Ban => {
self.mark_as_left(user_id, room_id);