@@ -38,6 +38,7 @@ type IRoomVersion interface {
3838 CheckCreateEvent (event PDU , sender spec.UserID , knownRoomVersion KnownRoomVersionFunc ) error
3939 DomainlessRoomIDs () bool
4040 PrivilegedCreators () bool
41+ StateDAGs () bool
4142}
4243
4344type KnownRoomVersionFunc func (RoomVersion ) bool
@@ -69,6 +70,7 @@ const (
6970 RoomVersionV12 RoomVersion = "12"
7071 RoomVersionPseudoIDs RoomVersion = "org.matrix.msc4014"
7172 RoomVersionHydra RoomVersion = "org.matrix.hydra.11"
73+ RoomVersionStateDAGs RoomVersion = "org.matrix.msc4242.12"
7274)
7375
7476// Event format constants.
@@ -417,6 +419,31 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
417419 domainlessRoomID : true ,
418420 privilegedCreators : true ,
419421 },
422+ // Based on v12
423+ RoomVersionStateDAGs : RoomVersionImpl {
424+ ver : RoomVersionStateDAGs ,
425+ stable : true ,
426+ stateResAlgorithm : StateResV2_1 ,
427+ eventFormat : EventFormatV2 ,
428+ eventIDFormat : EventIDFormatV3 ,
429+ redactionAlgorithm : redactEventJSONVStateDAGs ,
430+ signatureValidityCheckFunc : StrictValiditySignatureCheck ,
431+ canonicalJSONCheck : verifyEnforcedCanonicalJSON ,
432+ checkPowerLevelEvent : checkPowerLevelEventV3 ,
433+ restrictedJoinServernameFunc : extractAuthorisedViaServerName ,
434+ checkRestrictedJoin : checkRestrictedJoin ,
435+ parsePowerLevelsFunc : parseIntegerPowerLevels ,
436+ checkKnockingAllowedFunc : checkKnocking ,
437+ checkRestrictedJoinAllowedFunc : allowRestrictedJoins ,
438+ checkCreateEvent : checkCreateEventV3 ,
439+ // v3 versions relax the room ID check as the room ID has no domain now.
440+ newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV3 ,
441+ newEventFromTrustedJSONFunc : newEventFromTrustedJSONV3 ,
442+ newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV3 ,
443+ domainlessRoomID : true ,
444+ privilegedCreators : true ,
445+ stateDAGs : true ,
446+ },
420447}
421448
422449// RoomVersions returns information about room versions currently
@@ -501,7 +528,9 @@ type RoomVersionImpl struct {
501528 // whether auth_events should include the create event
502529 domainlessRoomID bool
503530 // creators have infinite PL
504- privilegedCreators bool
531+ privilegedCreators bool
532+ // Events form two graphs, a state DAG and an event DAG.
533+ stateDAGs bool
505534 checkRestrictedJoin func (ctx context.Context , localServerName spec.ServerName , roomQuerier RestrictedRoomJoinQuerier , roomID spec.RoomID , senderID spec.SenderID , privilegedCreators bool ) (string , error )
506535 restrictedJoinServernameFunc func (content []byte ) (spec.ServerName , error )
507536 checkRestrictedJoinAllowedFunc func () error
@@ -525,6 +554,10 @@ func (v RoomVersionImpl) DomainlessRoomIDs() bool {
525554 return v .domainlessRoomID
526555}
527556
557+ func (v RoomVersionImpl ) StateDAGs () bool {
558+ return v .stateDAGs
559+ }
560+
528561func (v RoomVersionImpl ) PrivilegedCreators () bool {
529562 return v .privilegedCreators
530563}
@@ -630,6 +663,7 @@ func (v RoomVersionImpl) NewEventBuilderFromProtoEvent(pe *ProtoEvent) *EventBui
630663 eb .StateKey = pe .StateKey
631664 eb .Type = pe .Type
632665 eb .Unsigned = pe .Unsigned
666+ eb .PrevStateEvents = pe .PrevStateEvents
633667 return eb
634668}
635669
0 commit comments