mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 18:43:10 -06:00
Actually only ignore user state events, ignore invites as well
This commit is contained in:
parent
26d1e3599a
commit
3c9665692f
|
|
@ -355,7 +355,7 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if event.Type() == spec.MRoomMember && !event.StateKeyEquals(userID) {
|
if event.Type() == spec.MRoomMember && !event.StateKeyEquals(userID) {
|
||||||
// With the exception of bans and invites which we do want to copy, we
|
// 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
|
// 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
|
// prevent us from being able to create membership events on behalf of other
|
||||||
// users anyway unless they are invites or bans.
|
// users anyway unless they are invites or bans.
|
||||||
|
|
@ -365,13 +365,13 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
}
|
}
|
||||||
switch membership {
|
switch membership {
|
||||||
case spec.Ban:
|
case spec.Ban:
|
||||||
case spec.Invite:
|
|
||||||
default:
|
default:
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// skip events that rely on a specific user being present
|
// skip events that rely on a specific user being present
|
||||||
if event.Type() != spec.MRoomMember && !event.StateKeyEquals("") {
|
sKey := *event.StateKey()
|
||||||
|
if event.Type() != spec.MRoomMember && len(sKey) > 0 && sKey[:1] == "@" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
state[gomatrixserverlib.StateKeyTuple{EventType: event.Type(), StateKey: *event.StateKey()}] = event
|
state[gomatrixserverlib.StateKeyTuple{EventType: event.Type(), StateKey: *event.StateKey()}] = event
|
||||||
|
|
|
||||||
|
|
@ -764,6 +764,7 @@ func TestUpgrade(t *testing.T) {
|
||||||
charlie := test.NewUser(t)
|
charlie := test.NewUser(t)
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
|
spaceChild := test.NewRoom(t, alice)
|
||||||
validateTuples := []gomatrixserverlib.StateKeyTuple{
|
validateTuples := []gomatrixserverlib.StateKeyTuple{
|
||||||
{EventType: spec.MRoomCreate},
|
{EventType: spec.MRoomCreate},
|
||||||
{EventType: spec.MRoomPowerLevels},
|
{EventType: spec.MRoomPowerLevels},
|
||||||
|
|
@ -772,8 +773,8 @@ func TestUpgrade(t *testing.T) {
|
||||||
{EventType: spec.MRoomCanonicalAlias},
|
{EventType: spec.MRoomCanonicalAlias},
|
||||||
{EventType: "m.room.tombstone"},
|
{EventType: "m.room.tombstone"},
|
||||||
{EventType: "m.custom.event"},
|
{EventType: "m.custom.event"},
|
||||||
|
{EventType: "m.space.child", StateKey: spaceChild.ID},
|
||||||
{EventType: "m.custom.event", StateKey: alice.ID},
|
{EventType: "m.custom.event", StateKey: alice.ID},
|
||||||
{EventType: spec.MRoomMember, StateKey: bob.ID}, // invite should be transferred
|
|
||||||
{EventType: spec.MRoomMember, StateKey: charlie.ID}, // ban should be transferred
|
{EventType: spec.MRoomMember, StateKey: charlie.ID}, // ban should be transferred
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -984,13 +985,10 @@ func TestUpgrade(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "invites/bans are transferred",
|
name: "bans are transferred",
|
||||||
upgradeUser: alice.ID,
|
upgradeUser: alice.ID,
|
||||||
roomFunc: func(rsAPI api.RoomserverInternalAPI) string {
|
roomFunc: func(rsAPI api.RoomserverInternalAPI) string {
|
||||||
r := test.NewRoom(t, alice)
|
r := test.NewRoom(t, alice)
|
||||||
r.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
|
|
||||||
"membership": spec.Invite,
|
|
||||||
}, test.WithStateKey(bob.ID))
|
|
||||||
r.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
|
r.CreateAndInsert(t, alice, spec.MRoomMember, map[string]interface{}{
|
||||||
"membership": spec.Ban,
|
"membership": spec.Ban,
|
||||||
}, test.WithStateKey(charlie.ID))
|
}, test.WithStateKey(charlie.ID))
|
||||||
|
|
@ -1002,6 +1000,21 @@ func TestUpgrade(t *testing.T) {
|
||||||
wantNewRoom: true,
|
wantNewRoom: true,
|
||||||
validateFunc: validate,
|
validateFunc: validate,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "space childs are transferred",
|
||||||
|
upgradeUser: alice.ID,
|
||||||
|
roomFunc: func(rsAPI api.RoomserverInternalAPI) string {
|
||||||
|
r := test.NewRoom(t, alice)
|
||||||
|
|
||||||
|
r.CreateAndInsert(t, alice, "m.space.child", map[string]interface{}{}, test.WithStateKey(spaceChild.ID))
|
||||||
|
if err := api.SendEvents(ctx, rsAPI, api.KindNew, r.Events(), "test", "test", "test", nil, false); err != nil {
|
||||||
|
t.Errorf("failed to send events: %v", err)
|
||||||
|
}
|
||||||
|
return r.ID
|
||||||
|
},
|
||||||
|
wantNewRoom: true,
|
||||||
|
validateFunc: validate,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "custom state is not taken to the new room", // https://github.com/matrix-org/dendrite/issues/2912
|
name: "custom state is not taken to the new room", // https://github.com/matrix-org/dendrite/issues/2912
|
||||||
upgradeUser: charlie.ID,
|
upgradeUser: charlie.ID,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue