mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-01-28 19:55:58 +03:00
Merge branch 'fixroomleave' into 'next'
fix: unable to leave room See merge request famedly/conduit!419
This commit is contained in:
commit
396dac6d82
1 changed files with 26 additions and 13 deletions
|
@ -1051,19 +1051,32 @@ pub async fn leave_room(user_id: &UserId, room_id: &RoomId) -> Result<()> {
|
||||||
);
|
);
|
||||||
let state_lock = mutex_state.lock().await;
|
let state_lock = mutex_state.lock().await;
|
||||||
|
|
||||||
let mut event: RoomMemberEventContent = serde_json::from_str(
|
let member_event = services().rooms.state_accessor.room_state_get(
|
||||||
services()
|
room_id,
|
||||||
.rooms
|
&StateEventType::RoomMember,
|
||||||
.state_accessor
|
user_id.as_str(),
|
||||||
.room_state_get(room_id, &StateEventType::RoomMember, user_id.as_str())?
|
)?;
|
||||||
.ok_or(Error::BadRequest(
|
|
||||||
ErrorKind::BadState,
|
// Fix for broken rooms
|
||||||
"Cannot leave a room you are not a member of.",
|
let member_event = match member_event {
|
||||||
))?
|
None => {
|
||||||
.content
|
error!("Trying to leave a room you are not a member of.");
|
||||||
.get(),
|
|
||||||
)
|
services().rooms.state_cache.update_membership(
|
||||||
.map_err(|_| Error::bad_database("Invalid member event in database."))?;
|
room_id,
|
||||||
|
user_id,
|
||||||
|
MembershipState::Leave,
|
||||||
|
user_id,
|
||||||
|
None,
|
||||||
|
true,
|
||||||
|
)?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
Some(e) => e,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut event: RoomMemberEventContent = serde_json::from_str(member_event.content.get())
|
||||||
|
.map_err(|_| Error::bad_database("Invalid member event in database."))?;
|
||||||
|
|
||||||
event.membership = MembershipState::Leave;
|
event.membership = MembershipState::Leave;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue