Copy invites as well as bans

This commit is contained in:
Neil Alexander 2022-04-04 17:20:06 +01:00
parent 4693f00a26
commit 5d62b8f2cd
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -346,11 +346,18 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
continue
}
if event.Type() == gomatrixserverlib.MRoomMember && !event.StateKeyEquals(userID) {
// With the exception of bans which we do want to copy, we should ignore
// membership events that aren't our own, as event auth will prevent us
// from being able to create membership events on behalf of other users
// anyway unless they are invites or bans.
if membership, err := event.Membership(); err == nil && membership != gomatrixserverlib.Ban {
// With the exception of bans and invites which we do want to copy, we
// should ignore membership events that aren't our own, as event auth will
// prevent us from being able to create membership events on behalf of other
// users anyway unless they are invites or bans.
membership, err := event.Membership()
if err != nil {
continue
}
switch membership {
case gomatrixserverlib.Ban:
case gomatrixserverlib.Invite:
default:
continue
}
}