@@ -33,8 +33,11 @@ type IRoomVersion interface {
3333 CheckNotificationLevels (senderLevel int64 , oldPowerLevels , newPowerLevels PowerLevelContent ) error
3434 CheckCanonicalJSON (input []byte ) error
3535 ParsePowerLevels (contentBytes []byte , c * PowerLevelContent ) error
36+ CheckCreateEvent (event PDU , knownRoomVersion knownRoomVersionFunc ) error
3637}
3738
39+ type knownRoomVersionFunc func (RoomVersion ) bool
40+
3841// StateResAlgorithm refers to a version of the state resolution algorithm.
3942type StateResAlgorithm int
4043
@@ -58,6 +61,7 @@ const (
5861 RoomVersionV8 RoomVersion = "8"
5962 RoomVersionV9 RoomVersion = "9"
6063 RoomVersionV10 RoomVersion = "10"
64+ RoomVersionV11 RoomVersion = "11"
6165 RoomVersionPseudoIDs RoomVersion = "org.matrix.msc4014"
6266)
6367
@@ -96,6 +100,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
96100 parsePowerLevelsFunc : parsePowerLevels ,
97101 checkKnockingAllowedFunc : disallowKnocking ,
98102 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
103+ checkCreateEvent : checkCreateEvent ,
99104 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV1 ,
100105 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV1 ,
101106 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV1 ,
@@ -115,6 +120,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
115120 parsePowerLevelsFunc : parsePowerLevels ,
116121 checkKnockingAllowedFunc : disallowKnocking ,
117122 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
123+ checkCreateEvent : checkCreateEvent ,
118124 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV1 ,
119125 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV1 ,
120126 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV1 ,
@@ -134,6 +140,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
134140 parsePowerLevelsFunc : parsePowerLevels ,
135141 checkKnockingAllowedFunc : disallowKnocking ,
136142 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
143+ checkCreateEvent : checkCreateEvent ,
137144 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
138145 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
139146 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -153,6 +160,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
153160 parsePowerLevelsFunc : parsePowerLevels ,
154161 checkKnockingAllowedFunc : disallowKnocking ,
155162 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
163+ checkCreateEvent : checkCreateEvent ,
156164 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
157165 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
158166 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -172,6 +180,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
172180 parsePowerLevelsFunc : parsePowerLevels ,
173181 checkKnockingAllowedFunc : disallowKnocking ,
174182 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
183+ checkCreateEvent : checkCreateEvent ,
175184 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
176185 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
177186 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -191,6 +200,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
191200 parsePowerLevelsFunc : parsePowerLevels ,
192201 checkKnockingAllowedFunc : disallowKnocking ,
193202 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
203+ checkCreateEvent : checkCreateEvent ,
194204 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
195205 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
196206 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -210,6 +220,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
210220 parsePowerLevelsFunc : parsePowerLevels ,
211221 checkKnockingAllowedFunc : checkKnocking ,
212222 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
223+ checkCreateEvent : checkCreateEvent ,
213224 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
214225 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
215226 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -229,6 +240,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
229240 parsePowerLevelsFunc : parsePowerLevels ,
230241 checkKnockingAllowedFunc : checkKnocking ,
231242 checkRestrictedJoinAllowedFunc : allowRestrictedJoins ,
243+ checkCreateEvent : checkCreateEvent ,
232244 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
233245 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
234246 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -248,6 +260,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
248260 parsePowerLevelsFunc : parsePowerLevels ,
249261 checkKnockingAllowedFunc : checkKnocking ,
250262 checkRestrictedJoinAllowedFunc : allowRestrictedJoins ,
263+ checkCreateEvent : checkCreateEvent ,
251264 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
252265 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
253266 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -267,6 +280,27 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
267280 parsePowerLevelsFunc : parseIntegerPowerLevels ,
268281 checkKnockingAllowedFunc : checkKnocking ,
269282 checkRestrictedJoinAllowedFunc : allowRestrictedJoins ,
283+ checkCreateEvent : checkCreateEvent ,
284+ newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
285+ newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
286+ newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
287+ },
288+ RoomVersionV11 : RoomVersionImpl {
289+ ver : RoomVersionV11 ,
290+ stable : true ,
291+ stateResAlgorithm : StateResV2 ,
292+ eventFormat : EventFormatV2 ,
293+ eventIDFormat : EventIDFormatV3 ,
294+ redactionAlgorithm : redactEventJSONV5 ,
295+ signatureValidityCheckFunc : StrictValiditySignatureCheck ,
296+ canonicalJSONCheck : verifyEnforcedCanonicalJSON ,
297+ notificationLevelCheck : checkNotificationLevels ,
298+ restrictedJoinServernameFunc : extractAuthorisedViaServerName ,
299+ checkRestrictedJoin : checkRestrictedJoin ,
300+ parsePowerLevelsFunc : parseIntegerPowerLevels ,
301+ checkKnockingAllowedFunc : checkKnocking ,
302+ checkRestrictedJoinAllowedFunc : allowRestrictedJoins ,
303+ checkCreateEvent : noCheckCreateEvent ,
270304 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
271305 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
272306 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -286,6 +320,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
286320 parsePowerLevelsFunc : parseIntegerPowerLevels ,
287321 checkKnockingAllowedFunc : checkKnocking ,
288322 checkRestrictedJoinAllowedFunc : allowRestrictedJoins ,
323+ checkCreateEvent : checkCreateEvent ,
289324 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
290325 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
291326 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -305,6 +340,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
305340 parsePowerLevelsFunc : parseIntegerPowerLevels ,
306341 checkKnockingAllowedFunc : checkKnocking ,
307342 checkRestrictedJoinAllowedFunc : disallowRestrictedJoins ,
343+ checkCreateEvent : checkCreateEvent ,
308344 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
309345 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
310346 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -323,6 +359,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
323359 checkRestrictedJoin : checkRestrictedJoin ,
324360 parsePowerLevelsFunc : parsePowerLevels ,
325361 checkKnockingAllowedFunc : checkKnocking ,
362+ checkCreateEvent : checkCreateEvent ,
326363 newEventFromUntrustedJSONFunc : newEventFromUntrustedJSONV2 ,
327364 newEventFromTrustedJSONFunc : newEventFromTrustedJSONV2 ,
328365 newEventFromTrustedJSONWithEventIDFunc : newEventFromTrustedJSONWithEventIDV2 ,
@@ -404,6 +441,7 @@ type RoomVersionImpl struct {
404441 restrictedJoinServernameFunc func (content []byte ) (spec.ServerName , error )
405442 checkRestrictedJoinAllowedFunc func () error
406443 checkKnockingAllowedFunc func (m * membershipAllower ) error
444+ checkCreateEvent func (e PDU , knownRoomVersion knownRoomVersionFunc ) error
407445 newEventFromUntrustedJSONFunc func (eventJSON []byte , roomVersion IRoomVersion ) (result PDU , err error )
408446 newEventFromTrustedJSONFunc func (eventJSON []byte , redacted bool , roomVersion IRoomVersion ) (result PDU , err error )
409447 newEventFromTrustedJSONWithEventIDFunc func (eventID string , eventJSON []byte , redacted bool , roomVersion IRoomVersion ) (result PDU , err error )
@@ -470,6 +508,10 @@ func (v RoomVersionImpl) ParsePowerLevels(contentBytes []byte, c *PowerLevelCont
470508 return v .parsePowerLevelsFunc (contentBytes , c )
471509}
472510
511+ func (v RoomVersionImpl ) CheckCreateEvent (event PDU , knownRoomVersion knownRoomVersionFunc ) error {
512+ return v .checkCreateEvent (event , knownRoomVersion )
513+ }
514+
473515func (v RoomVersionImpl ) CheckRestrictedJoin (
474516 ctx context.Context ,
475517 localServerName spec.ServerName ,
0 commit comments