From 52795b060230b8e75935ad08a72799e76daf2b8b Mon Sep 17 00:00:00 2001 From: FrenchGithubUser Date: Fri, 17 Apr 2026 13:43:24 +0200 Subject: [PATCH 1/3] feat: add CreatorInCreateEvent to help with default room v11 Signed-off-by: Thomas Traineau t.traineau@famedly.com --- eventversion.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/eventversion.go b/eventversion.go index 9f38585d..7b9a5922 100644 --- a/eventversion.go +++ b/eventversion.go @@ -39,6 +39,7 @@ type IRoomVersion interface { DomainlessRoomIDs() bool PrivilegedCreators() bool StateDAGs() bool + CreatorInCreateEvent() bool } type KnownRoomVersionFunc func(RoomVersion) bool @@ -110,6 +111,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: disallowKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV1, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV1, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV1, @@ -130,6 +132,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: disallowKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV1, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV1, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV1, @@ -150,6 +153,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: disallowKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -170,6 +174,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: disallowKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -190,6 +195,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: disallowKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -210,6 +216,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: disallowKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -230,6 +237,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -250,6 +258,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: allowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -270,6 +279,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: allowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -290,6 +300,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: allowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -353,6 +364,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: allowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -373,6 +385,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -392,6 +405,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ parsePowerLevelsFunc: parsePowerLevels, checkKnockingAllowedFunc: checkKnocking, checkCreateEvent: checkCreateEventV1, + creatorInCreateEvent: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -529,6 +543,8 @@ type RoomVersionImpl struct { domainlessRoomID bool // creators have infinite PL privilegedCreators bool + // creator field is present in the create event content + creatorInCreateEvent bool // Events form two graphs, a state DAG and an event DAG. stateDAGs bool 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 { return v.privilegedCreators } +func (v RoomVersionImpl) CreatorInCreateEvent() bool { + return v.creatorInCreateEvent +} + // StateResAlgorithm returns the state resolution for the given room version. func (v RoomVersionImpl) StateResAlgorithm() StateResAlgorithm { return v.stateResAlgorithm From 529d3f0d7d838b66e4753294a0fece8d5e4ae6a6 Mon Sep 17 00:00:00 2001 From: FrenchGithubUser Date: Mon, 20 Apr 2026 11:14:46 +0200 Subject: [PATCH 2/3] feat: add strictEventByteLimits to help with default room v11 Signed-off-by: Thomas Traineau t.traineau@famedly.com --- eventversion.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/eventversion.go b/eventversion.go index 7b9a5922..084df12c 100644 --- a/eventversion.go +++ b/eventversion.go @@ -40,6 +40,9 @@ type IRoomVersion interface { PrivilegedCreators() bool StateDAGs() bool CreatorInCreateEvent() bool + // StrictEventByteLimits returns true if this room version enforces field + // length limits in bytes rather than Unicode codepoints (introduced in v11 for synapse). + StrictEventByteLimits() bool } type KnownRoomVersionFunc func(RoomVersion) bool @@ -321,6 +324,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: allowRestrictedJoins, checkCreateEvent: checkCreateEventV2, + strictEventByteLimits: true, newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, @@ -341,6 +345,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: allowRestrictedJoins, checkCreateEvent: checkCreateEventV3, + strictEventByteLimits: true, // v3 versions relax the room ID check as the room ID has no domain now. newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV3, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV3, @@ -450,6 +455,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ checkKnockingAllowedFunc: checkKnocking, checkRestrictedJoinAllowedFunc: allowRestrictedJoins, checkCreateEvent: checkCreateEventV3, + strictEventByteLimits: true, // v3 versions relax the room ID check as the room ID has no domain now. newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV3, newEventFromTrustedJSONFunc: newEventFromTrustedJSONV3, @@ -545,6 +551,8 @@ type RoomVersionImpl struct { privilegedCreators bool // creator field is present in the create event content creatorInCreateEvent bool + // field length limits are in bytes rather than Unicode codepoints + strictEventByteLimits bool // Events form two graphs, a state DAG and an event DAG. stateDAGs bool checkRestrictedJoin func(ctx context.Context, localServerName spec.ServerName, roomQuerier RestrictedRoomJoinQuerier, roomID spec.RoomID, senderID spec.SenderID, privilegedCreators bool) (string, error) @@ -582,6 +590,10 @@ func (v RoomVersionImpl) CreatorInCreateEvent() bool { return v.creatorInCreateEvent } +func (v RoomVersionImpl) StrictEventByteLimits() bool { + return v.strictEventByteLimits +} + // StateResAlgorithm returns the state resolution for the given room version. func (v RoomVersionImpl) StateResAlgorithm() StateResAlgorithm { return v.stateResAlgorithm From 3661833e110ae631de02781045d9dfb4699df7d9 Mon Sep 17 00:00:00 2001 From: FrenchGithubUser Date: Thu, 30 Apr 2026 11:50:48 +0200 Subject: [PATCH 3/3] chore: better document CreatorInCreateEvent --- eventversion.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eventversion.go b/eventversion.go index 084df12c..596458e2 100644 --- a/eventversion.go +++ b/eventversion.go @@ -39,6 +39,10 @@ type IRoomVersion interface { DomainlessRoomIDs() bool PrivilegedCreators() bool StateDAGs() bool + // returns true if this room version requires a "creator" field + // in the m.room.create event content (room versions 1–10). The field + // was removed in room version 11, where the creator is instead derived from + // the event sender. CreatorInCreateEvent() bool // StrictEventByteLimits returns true if this room version enforces field // length limits in bytes rather than Unicode codepoints (introduced in v11 for synapse). @@ -549,7 +553,10 @@ type RoomVersionImpl struct { domainlessRoomID bool // creators have infinite PL privilegedCreators bool - // creator field is present in the create event content + // the m.room.create content includes a "creator" field + // (room versions 1–10). This is distinct from privilegedCreators, which + // governs power-levels; this flag only controls whether the field + // must be present in the create event content. creatorInCreateEvent bool // field length limits are in bytes rather than Unicode codepoints strictEventByteLimits bool