diff --git a/roomserver/internal/input/input_events.go b/roomserver/internal/input/input_events.go index 81e2e2b9d..db3cd1986 100644 --- a/roomserver/internal/input/input_events.go +++ b/roomserver/internal/input/input_events.go @@ -526,8 +526,19 @@ func (r *Inputer) processRoomEvent( // leavePseudoIDRoom leaves/kicks a user in the event of a membership event redaction. // TODO: This doesn't play well with users re-joining rooms, as in this case we have multiple join events with a mxid_mapping. func (r *Inputer) leavePseudoIDRoom(ctx context.Context, roomID spec.RoomID, originalRedactedEvent, redactionEvent gomatrixserverlib.PDU) error { + + stateKey := originalRedactedEvent.StateKey() + currentStateEvent, err := r.DB.GetStateEvent(ctx, roomID.String(), originalRedactedEvent.Type(), *stateKey) + if err != nil { + return err + } + // If the redacted event is NOT the current state event, do nothing + if currentStateEvent.EventID() != originalRedactedEvent.EventID() { + return nil + } + var memberContent gomatrixserverlib.MemberContent - if err := json.Unmarshal(originalRedactedEvent.Content(), &memberContent); err != nil { + if err = json.Unmarshal(originalRedactedEvent.Content(), &memberContent); err != nil { return err } if memberContent.Membership != spec.Join { @@ -549,9 +560,6 @@ func (r *Inputer) leavePseudoIDRoom(ctx context.Context, roomID spec.RoomID, ori return nil } - // check that the redacted event is the _current_ membership event - stateKey := originalRedactedEvent.StateKey() - signingIdentity, err := r.SigningIdentity(ctx, roomID, *userID) if err != nil { return err