Check prev_content for all leave events

This commit is contained in:
Tulir Asokan 2021-11-01 12:52:51 +02:00
parent d24a8821c1
commit c85b003fe8

View file

@ -274,14 +274,14 @@ func (mx *MatrixHandler) HandleMembership(evt *event.Event) {
isSelf := id.UserID(evt.GetStateKey()) == evt.Sender
if content.Membership == event.MembershipLeave {
if isSelf {
if evt.Unsigned.PrevContent != nil {
_ = evt.Unsigned.PrevContent.ParseRaw(evt.Type)
prevContent, ok := evt.Unsigned.PrevContent.Parsed.(*event.MemberEventContent)
if ok && prevContent.Membership != "join" {
return
}
if evt.Unsigned.PrevContent != nil {
_ = evt.Unsigned.PrevContent.ParseRaw(evt.Type)
prevContent, ok := evt.Unsigned.PrevContent.Parsed.(*event.MemberEventContent)
if ok && prevContent.Membership != "join" {
return
}
}
if isSelf {
portal.HandleMatrixLeave(user)
} else {
portal.HandleMatrixKick(user, evt)