Skip to content

Commit 52795b0

Browse files
feat: add CreatorInCreateEvent to help with default room v11
Signed-off-by: Thomas Traineau t.traineau@famedly.com
1 parent 20c9de3 commit 52795b0

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

eventversion.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type IRoomVersion interface {
3939
DomainlessRoomIDs() bool
4040
PrivilegedCreators() bool
4141
StateDAGs() bool
42+
CreatorInCreateEvent() bool
4243
}
4344

4445
type KnownRoomVersionFunc func(RoomVersion) bool
@@ -110,6 +111,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
110111
checkKnockingAllowedFunc: disallowKnocking,
111112
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
112113
checkCreateEvent: checkCreateEventV1,
114+
creatorInCreateEvent: true,
113115
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV1,
114116
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV1,
115117
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV1,
@@ -130,6 +132,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
130132
checkKnockingAllowedFunc: disallowKnocking,
131133
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
132134
checkCreateEvent: checkCreateEventV1,
135+
creatorInCreateEvent: true,
133136
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV1,
134137
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV1,
135138
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV1,
@@ -150,6 +153,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
150153
checkKnockingAllowedFunc: disallowKnocking,
151154
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
152155
checkCreateEvent: checkCreateEventV1,
156+
creatorInCreateEvent: true,
153157
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
154158
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
155159
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -170,6 +174,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
170174
checkKnockingAllowedFunc: disallowKnocking,
171175
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
172176
checkCreateEvent: checkCreateEventV1,
177+
creatorInCreateEvent: true,
173178
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
174179
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
175180
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -190,6 +195,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
190195
checkKnockingAllowedFunc: disallowKnocking,
191196
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
192197
checkCreateEvent: checkCreateEventV1,
198+
creatorInCreateEvent: true,
193199
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
194200
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
195201
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -210,6 +216,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
210216
checkKnockingAllowedFunc: disallowKnocking,
211217
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
212218
checkCreateEvent: checkCreateEventV1,
219+
creatorInCreateEvent: true,
213220
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
214221
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
215222
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -230,6 +237,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
230237
checkKnockingAllowedFunc: checkKnocking,
231238
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
232239
checkCreateEvent: checkCreateEventV1,
240+
creatorInCreateEvent: true,
233241
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
234242
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
235243
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -250,6 +258,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
250258
checkKnockingAllowedFunc: checkKnocking,
251259
checkRestrictedJoinAllowedFunc: allowRestrictedJoins,
252260
checkCreateEvent: checkCreateEventV1,
261+
creatorInCreateEvent: true,
253262
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
254263
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
255264
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -270,6 +279,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
270279
checkKnockingAllowedFunc: checkKnocking,
271280
checkRestrictedJoinAllowedFunc: allowRestrictedJoins,
272281
checkCreateEvent: checkCreateEventV1,
282+
creatorInCreateEvent: true,
273283
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
274284
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
275285
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -290,6 +300,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
290300
checkKnockingAllowedFunc: checkKnocking,
291301
checkRestrictedJoinAllowedFunc: allowRestrictedJoins,
292302
checkCreateEvent: checkCreateEventV1,
303+
creatorInCreateEvent: true,
293304
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
294305
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
295306
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -353,6 +364,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
353364
checkKnockingAllowedFunc: checkKnocking,
354365
checkRestrictedJoinAllowedFunc: allowRestrictedJoins,
355366
checkCreateEvent: checkCreateEventV1,
367+
creatorInCreateEvent: true,
356368
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
357369
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
358370
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -373,6 +385,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
373385
checkKnockingAllowedFunc: checkKnocking,
374386
checkRestrictedJoinAllowedFunc: disallowRestrictedJoins,
375387
checkCreateEvent: checkCreateEventV1,
388+
creatorInCreateEvent: true,
376389
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
377390
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
378391
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -392,6 +405,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{
392405
parsePowerLevelsFunc: parsePowerLevels,
393406
checkKnockingAllowedFunc: checkKnocking,
394407
checkCreateEvent: checkCreateEventV1,
408+
creatorInCreateEvent: true,
395409
newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2,
396410
newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2,
397411
newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2,
@@ -529,6 +543,8 @@ type RoomVersionImpl struct {
529543
domainlessRoomID bool
530544
// creators have infinite PL
531545
privilegedCreators bool
546+
// creator field is present in the create event content
547+
creatorInCreateEvent bool
532548
// Events form two graphs, a state DAG and an event DAG.
533549
stateDAGs bool
534550
checkRestrictedJoin func(ctx context.Context, localServerName spec.ServerName, roomQuerier RestrictedRoomJoinQuerier, roomID spec.RoomID, senderID spec.SenderID, privilegedCreators bool) (string, error)
@@ -562,6 +578,10 @@ func (v RoomVersionImpl) PrivilegedCreators() bool {
562578
return v.privilegedCreators
563579
}
564580

581+
func (v RoomVersionImpl) CreatorInCreateEvent() bool {
582+
return v.creatorInCreateEvent
583+
}
584+
565585
// StateResAlgorithm returns the state resolution for the given room version.
566586
func (v RoomVersionImpl) StateResAlgorithm() StateResAlgorithm {
567587
return v.stateResAlgorithm

0 commit comments

Comments
 (0)