From 9f19a2025d9a561d216786c8649711b49063cc8e Mon Sep 17 00:00:00 2001 From: morguldir Date: Sat, 11 May 2024 01:26:00 +0200 Subject: [PATCH] Revert "feat(membership): check if user already has the membership that is requested to be set" This reverts commit 321a6ca0fefccc87b334d7410aba18c512fcee2b. These checks were not working as intended, resulting in the unban button not working The join check gets kept since it slightly reduces the amount of sent joins in some cases This check will probably be replaced soon for a more universal solution to the "made no change" issue Signed-off-by: morguldir --- src/api/client_server/membership.rs | 31 ----------------------------- 1 file changed, 31 deletions(-) diff --git a/src/api/client_server/membership.rs b/src/api/client_server/membership.rs index a1908327..4fad8cf2 100644 --- a/src/api/client_server/membership.rs +++ b/src/api/client_server/membership.rs @@ -317,15 +317,6 @@ pub(crate) async fn invite_user_route(body: Ruma) -> R pub(crate) async fn kick_user_route(body: Ruma) -> Result { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); - if let Ok(true) = services() - .rooms - .state_cache - .is_left(sender_user, &body.room_id) - { - info!("{} is not in room {}", &body.user_id, &body.room_id); - return Ok(kick_user::v3::Response {}); - } - let mut event: RoomMemberEventContent = serde_json::from_str( services() .rooms @@ -382,17 +373,6 @@ pub(crate) async fn kick_user_route(body: Ruma) -> Resul pub(crate) async fn ban_user_route(body: Ruma) -> Result { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); - if let Ok(Some(membership_event)) = services() - .rooms - .state_accessor - .get_member(&body.room_id, sender_user) - { - if membership_event.membership == MembershipState::Ban { - info!("{} is already banned in {}", &body.user_id, &body.room_id); - return Ok(ban_user::v3::Response {}); - } - } - let event = services() .rooms .state_accessor @@ -462,17 +442,6 @@ pub(crate) async fn ban_user_route(body: Ruma) -> Result< pub(crate) async fn unban_user_route(body: Ruma) -> Result { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); - if let Ok(Some(membership_event)) = services() - .rooms - .state_accessor - .get_member(&body.room_id, sender_user) - { - if membership_event.membership != MembershipState::Ban { - info!("{} is already unbanned in {}", &body.user_id, &body.room_id); - return Ok(unban_user::v3::Response {}); - } - } - let mut event: RoomMemberEventContent = serde_json::from_str( services() .rooms