fix membership route ABA's
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
8077e910f6
commit
454dd43d4c
1 changed files with 21 additions and 21 deletions
|
@ -7,7 +7,7 @@ use std::{
|
||||||
|
|
||||||
use axum_client_ip::InsecureClientIp;
|
use axum_client_ip::InsecureClientIp;
|
||||||
use conduit::{
|
use conduit::{
|
||||||
debug, error, info, trace, utils,
|
debug, debug_warn, error, info, trace, utils,
|
||||||
utils::{math::continue_exponential_backoff_secs, mutex_map},
|
utils::{math::continue_exponential_backoff_secs, mutex_map},
|
||||||
warn, Error, PduEvent, Result,
|
warn, Error, PduEvent, Result,
|
||||||
};
|
};
|
||||||
|
@ -366,6 +366,12 @@ pub(crate) async fn invite_user_route(
|
||||||
pub(crate) async fn kick_user_route(body: Ruma<kick_user::v3::Request>) -> Result<kick_user::v3::Response> {
|
pub(crate) async fn kick_user_route(body: Ruma<kick_user::v3::Request>) -> Result<kick_user::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
let state_lock = services()
|
||||||
|
.globals
|
||||||
|
.roomid_mutex_state
|
||||||
|
.lock(&body.room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
let mut event: RoomMemberEventContent = serde_json::from_str(
|
let mut event: RoomMemberEventContent = serde_json::from_str(
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
|
@ -383,12 +389,6 @@ pub(crate) async fn kick_user_route(body: Ruma<kick_user::v3::Request>) -> Resul
|
||||||
event.membership = MembershipState::Leave;
|
event.membership = MembershipState::Leave;
|
||||||
event.reason.clone_from(&body.reason);
|
event.reason.clone_from(&body.reason);
|
||||||
|
|
||||||
let state_lock = services()
|
|
||||||
.globals
|
|
||||||
.roomid_mutex_state
|
|
||||||
.lock(&body.room_id)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
|
@ -417,6 +417,12 @@ pub(crate) async fn kick_user_route(body: Ruma<kick_user::v3::Request>) -> Resul
|
||||||
pub(crate) async fn ban_user_route(body: Ruma<ban_user::v3::Request>) -> Result<ban_user::v3::Response> {
|
pub(crate) async fn ban_user_route(body: Ruma<ban_user::v3::Request>) -> Result<ban_user::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
let state_lock = services()
|
||||||
|
.globals
|
||||||
|
.roomid_mutex_state
|
||||||
|
.lock(&body.room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
let event = services()
|
let event = services()
|
||||||
.rooms
|
.rooms
|
||||||
.state_accessor
|
.state_accessor
|
||||||
|
@ -447,12 +453,6 @@ pub(crate) async fn ban_user_route(body: Ruma<ban_user::v3::Request>) -> Result<
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let state_lock = services()
|
|
||||||
.globals
|
|
||||||
.roomid_mutex_state
|
|
||||||
.lock(&body.room_id)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
|
@ -481,6 +481,12 @@ pub(crate) async fn ban_user_route(body: Ruma<ban_user::v3::Request>) -> Result<
|
||||||
pub(crate) async fn unban_user_route(body: Ruma<unban_user::v3::Request>) -> Result<unban_user::v3::Response> {
|
pub(crate) async fn unban_user_route(body: Ruma<unban_user::v3::Request>) -> Result<unban_user::v3::Response> {
|
||||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||||
|
|
||||||
|
let state_lock = services()
|
||||||
|
.globals
|
||||||
|
.roomid_mutex_state
|
||||||
|
.lock(&body.room_id)
|
||||||
|
.await;
|
||||||
|
|
||||||
let mut event: RoomMemberEventContent = serde_json::from_str(
|
let mut event: RoomMemberEventContent = serde_json::from_str(
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
|
@ -496,12 +502,6 @@ pub(crate) async fn unban_user_route(body: Ruma<unban_user::v3::Request>) -> Res
|
||||||
event.reason.clone_from(&body.reason);
|
event.reason.clone_from(&body.reason);
|
||||||
event.join_authorized_via_users_server = None;
|
event.join_authorized_via_users_server = None;
|
||||||
|
|
||||||
let state_lock = services()
|
|
||||||
.globals
|
|
||||||
.roomid_mutex_state
|
|
||||||
.lock(&body.room_id)
|
|
||||||
.await;
|
|
||||||
|
|
||||||
services()
|
services()
|
||||||
.rooms
|
.rooms
|
||||||
.timeline
|
.timeline
|
||||||
|
@ -656,6 +656,8 @@ pub async fn join_room_by_id_helper(
|
||||||
sender_user: &UserId, room_id: &RoomId, reason: Option<String>, servers: &[OwnedServerName],
|
sender_user: &UserId, room_id: &RoomId, reason: Option<String>, servers: &[OwnedServerName],
|
||||||
third_party_signed: Option<&ThirdPartySigned>,
|
third_party_signed: Option<&ThirdPartySigned>,
|
||||||
) -> Result<join_room_by_id::v3::Response> {
|
) -> Result<join_room_by_id::v3::Response> {
|
||||||
|
let state_lock = services().rooms.state.mutex.lock(room_id).await;
|
||||||
|
|
||||||
if matches!(services().rooms.state_cache.is_joined(sender_user, room_id), Ok(true)) {
|
if matches!(services().rooms.state_cache.is_joined(sender_user, room_id), Ok(true)) {
|
||||||
info!("{sender_user} is already joined in {room_id}");
|
info!("{sender_user} is already joined in {room_id}");
|
||||||
return Ok(join_room_by_id::v3::Response {
|
return Ok(join_room_by_id::v3::Response {
|
||||||
|
@ -663,8 +665,6 @@ pub async fn join_room_by_id_helper(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let state_lock = services().globals.roomid_mutex_state.lock(room_id).await;
|
|
||||||
|
|
||||||
// Ask a remote server if we are not participating in this room
|
// Ask a remote server if we are not participating in this room
|
||||||
if !services()
|
if !services()
|
||||||
.rooms
|
.rooms
|
||||||
|
|
Loading…
Add table
Reference in a new issue