Room version 12 (#3623)
Some checks are pending
Dendrite / Sytest (SQLite Cgo) (push) Blocked by required conditions
Dendrite / WASM build test (push) Waiting to run
Dendrite / Linting (push) Waiting to run
Dendrite / Unit tests (push) Waiting to run
Dendrite / Build for Linux (push) Waiting to run
Dendrite / Build for Windows (push) Waiting to run
Dendrite / Initial tests passed (push) Blocked by required conditions
Dendrite / Integration tests (push) Blocked by required conditions
Dendrite / Upgrade tests (push) Blocked by required conditions
Dendrite / Upgrade tests from HEAD-2 (push) Blocked by required conditions
Dendrite / Sytest (PostgreSQL) (push) Blocked by required conditions
Dendrite / Sytest (SQLite native) (push) Blocked by required conditions
Dendrite / Complement (PostgreSQL) (push) Blocked by required conditions
Dendrite / Complement (SQLite native) (push) Blocked by required conditions
Dendrite / Complement (SQLite Cgo) (push) Blocked by required conditions
Dendrite / Integration tests passed (push) Blocked by required conditions
Dendrite / Update Docker images (push) Blocked by required conditions

This commit is contained in:
Kegan Dougal 2025-08-11 20:59:47 +01:00 committed by GitHub
parent a408b24d28
commit 4d93d921be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 530 additions and 208 deletions

View file

@ -37,7 +37,7 @@ type CanonicalAlias struct {
// if they have not been specified.
// http://matrix.org/docs/spec/client_server/r0.2.0.html#m-room-power-levels
// https://github.com/matrix-org/synapse/blob/v0.19.2/synapse/handlers/room.py#L294
func InitialPowerLevelsContent(roomCreator string) (c gomatrixserverlib.PowerLevelContent) {
func InitialPowerLevelsContent(roomVersion gomatrixserverlib.IRoomVersion, roomCreator string) (c gomatrixserverlib.PowerLevelContent) {
c.Defaults()
c.Events = map[string]int64{
"m.room.name": 50,
@ -49,7 +49,12 @@ func InitialPowerLevelsContent(roomCreator string) (c gomatrixserverlib.PowerLev
"m.room.encryption": 100,
"m.room.server_acl": 100,
}
c.Users = map[string]int64{roomCreator: 100}
c.Users = map[string]int64{}
if roomVersion.PrivilegedCreators() {
c.Events["m.room.tombstone"] = 150
} else {
c.Users[roomCreator] = 100
}
return c
}

View file

@ -67,16 +67,24 @@ func BuildEvent(
identity *fclient.SigningIdentity, evTime time.Time,
eventsNeeded *gomatrixserverlib.StateNeeded, queryRes *api.QueryLatestEventsAndStateResponse,
) (*types.HeaderedEvent, error) {
if err := addPrevEventsToEvent(proto, eventsNeeded, queryRes); err != nil {
return nil, err
}
verImpl, err := gomatrixserverlib.GetRoomVersion(queryRes.RoomVersion)
if err != nil {
return nil, err
}
proto.Version = verImpl
if err = addPrevEventsToEvent(proto, eventsNeeded, queryRes); err != nil {
return nil, err
}
builder := verImpl.NewEventBuilderFromProtoEvent(proto)
if verImpl.DomainlessRoomIDs() && builder.RoomID != "" && proto.Type == spec.MRoomCreate && proto.StateKey != nil && *proto.StateKey == "" {
return nil, gomatrixserverlib.EventValidationError{
Message: "cannot resend m.room.create event",
Code: 400,
}
}
event, err := builder.Build(
evTime, identity.ServerName, identity.KeyID,
identity.PrivateKey,
@ -136,8 +144,22 @@ func addPrevEventsToEvent(
if err != nil {
return fmt.Errorf("eventsNeeded.AuthEventReferences: %w", err)
}
var authEventIDs []string
if builder.Version.DomainlessRoomIDs() && len(builder.RoomID) > 0 {
// the room ID is the create event so we shouldn't set it in auth_events
authEventIDs = make([]string, 0, len(refs))
createEventID := fmt.Sprintf("$%s", builder.RoomID[1:])
for _, id := range refs {
if id == createEventID {
continue
}
authEventIDs = append(authEventIDs, id)
}
} else {
authEventIDs = refs
}
builder.AuthEvents, builder.PrevEvents = truncateAuthAndPrevEvents(refs, queryRes.LatestEvents)
builder.AuthEvents, builder.PrevEvents = truncateAuthAndPrevEvents(authEventIDs, queryRes.LatestEvents)
return nil
}