-
Notifications
You must be signed in to change notification settings - Fork 57
feat: add CreatorInCreateEvent to help with default room v11 #465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,10 @@ type IRoomVersion interface { | |
| DomainlessRoomIDs() bool | ||
| 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 | ||
|
|
@@ -110,6 +114,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: disallowKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think most of these should be false, if I understand it right?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is false from room v11 and above |
||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV1, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV1, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV1, | ||
|
|
@@ -130,6 +135,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: disallowKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV1, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV1, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV1, | ||
|
|
@@ -150,6 +156,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: disallowKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -170,6 +177,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: disallowKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -190,6 +198,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: disallowKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -210,6 +219,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: disallowKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -230,6 +240,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -250,6 +261,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkRestrictedJoinAllowedFunc: allowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -270,6 +282,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkRestrictedJoinAllowedFunc: allowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -290,6 +303,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkRestrictedJoinAllowedFunc: allowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -310,6 +324,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkRestrictedJoinAllowedFunc: allowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV2, | ||
| strictEventByteLimits: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -330,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, | ||
|
|
@@ -353,6 +369,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkRestrictedJoinAllowedFunc: allowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -373,6 +390,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkRestrictedJoinAllowedFunc: disallowRestrictedJoins, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -392,6 +410,7 @@ var roomVersionMeta = map[RoomVersion]IRoomVersion{ | |
| parsePowerLevelsFunc: parsePowerLevels, | ||
| checkKnockingAllowedFunc: checkKnocking, | ||
| checkCreateEvent: checkCreateEventV1, | ||
| creatorInCreateEvent: true, | ||
| newEventFromUntrustedJSONFunc: newEventFromUntrustedJSONV2, | ||
| newEventFromTrustedJSONFunc: newEventFromTrustedJSONV2, | ||
| newEventFromTrustedJSONWithEventIDFunc: newEventFromTrustedJSONWithEventIDV2, | ||
|
|
@@ -436,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, | ||
|
|
@@ -529,6 +549,10 @@ type RoomVersionImpl struct { | |
| domainlessRoomID bool | ||
| // creators have infinite PL | ||
| privilegedCreators bool | ||
|
FrenchGithubUser marked this conversation as resolved.
|
||
| // 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) | ||
|
|
@@ -562,6 +586,14 @@ func (v RoomVersionImpl) PrivilegedCreators() bool { | |
| return v.privilegedCreators | ||
| } | ||
|
|
||
| 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 | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.