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 isSelf := id.UserID(evt.GetStateKey()) == evt.Sender
if content.Membership == event.MembershipLeave { if content.Membership == event.MembershipLeave {
if isSelf { if evt.Unsigned.PrevContent != nil {
if evt.Unsigned.PrevContent != nil { _ = evt.Unsigned.PrevContent.ParseRaw(evt.Type)
_ = evt.Unsigned.PrevContent.ParseRaw(evt.Type) prevContent, ok := evt.Unsigned.PrevContent.Parsed.(*event.MemberEventContent)
prevContent, ok := evt.Unsigned.PrevContent.Parsed.(*event.MemberEventContent) if ok && prevContent.Membership != "join" {
if ok && prevContent.Membership != "join" { return
return
}
} }
}
if isSelf {
portal.HandleMatrixLeave(user) portal.HandleMatrixLeave(user)
} else { } else {
portal.HandleMatrixKick(user, evt) portal.HandleMatrixKick(user, evt)