mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-30 00:44:34 +02:00
fix: Ignore existing membership when room is disconnected
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 1s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 1s
Checks / Rust / Clippy (push) Failing after 16s
Checks / Rust / Cargo Test (push) Failing after 27s
Some checks failed
Documentation / Build and Deploy Documentation (push) Has been skipped
Checks / Prefligit / prefligit (push) Failing after 1s
Release Docker Image / define-variables (push) Failing after 1s
Release Docker Image / build-image (linux/amd64, release, linux-amd64, base) (push) Has been skipped
Release Docker Image / build-image (linux/arm64, release, linux-arm64, base) (push) Has been skipped
Release Docker Image / merge (push) Has been skipped
Checks / Rust / Format (push) Failing after 1s
Checks / Rust / Clippy (push) Failing after 16s
Checks / Rust / Cargo Test (push) Failing after 27s
This commit is contained in:
parent
52e042cb06
commit
9b6ac6c45f
1 changed files with 20 additions and 12 deletions
|
@ -925,24 +925,32 @@ pub async fn join_room_by_id_helper(
|
||||||
return Ok(join_room_by_id::v3::Response { room_id: room_id.into() });
|
return Ok(join_room_by_id::v3::Response { room_id: room_id.into() });
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(membership) = services
|
|
||||||
.rooms
|
|
||||||
.state_accessor
|
|
||||||
.get_member(room_id, sender_user)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
if membership.membership == MembershipState::Ban {
|
|
||||||
debug_warn!("{sender_user} is banned from {room_id} but attempted to join");
|
|
||||||
return Err!(Request(Forbidden("You are banned from the room.")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let server_in_room = services
|
let server_in_room = services
|
||||||
.rooms
|
.rooms
|
||||||
.state_cache
|
.state_cache
|
||||||
.server_in_room(services.globals.server_name(), room_id)
|
.server_in_room(services.globals.server_name(), room_id)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
// Only check our known membership if we're already in the room.
|
||||||
|
// See: https://forgejo.ellis.link/continuwuation/continuwuity/issues/855
|
||||||
|
let membership = if server_in_room {
|
||||||
|
services
|
||||||
|
.rooms
|
||||||
|
.state_accessor
|
||||||
|
.get_member(room_id, sender_user)
|
||||||
|
.await
|
||||||
|
} else {
|
||||||
|
debug!("Ignoring local state for join {room_id}, we aren't in the room yet.");
|
||||||
|
Ok(RoomMemberEventContent::new(MembershipState::Leave))
|
||||||
|
};
|
||||||
|
if let Ok(m) = membership {
|
||||||
|
if m.membership == MembershipState::Ban {
|
||||||
|
debug_warn!("{sender_user} is banned from {room_id} but attempted to join");
|
||||||
|
// TODO: return reason
|
||||||
|
return Err!(Request(Forbidden("You are banned from the room.")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let local_join = server_in_room
|
let local_join = server_in_room
|
||||||
|| servers.is_empty()
|
|| servers.is_empty()
|
||||||
|| (servers.len() == 1 && services.globals.server_is_ours(&servers[0]));
|
|| (servers.len() == 1 && services.globals.server_is_ours(&servers[0]));
|
||||||
|
|
Loading…
Add table
Reference in a new issue