Implement new RoomVersionImpl API (#3062)

As outlined in https://github.com/matrix-org/gomatrixserverlib/pull/368

The main change Dendrite side is that `RoomVersion` no longer has any
methods on it. Instead, you need to bounce via `gmsl.GetRoomVersion`.

It's very interesting to see where exactly Dendrite cares about this.
For some places it's creating events (fine) but others are way more
specific. Those areas will need to migrate to GMSL at some point.
This commit is contained in:
kegsay 2023-04-21 17:06:29 +01:00 committed by GitHub
parent 71eeccf34a
commit 1647213fac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 144 additions and 65 deletions

View file

@ -884,12 +884,14 @@ func (r *Queryer) QueryRestrictedJoinAllowed(ctx context.Context, req *api.Query
if roomInfo == nil || roomInfo.IsStub() {
return nil // fmt.Errorf("room %q doesn't exist or is stub room", req.RoomID)
}
verImpl, err := gomatrixserverlib.GetRoomVersion(roomInfo.RoomVersion)
if err != nil {
return err
}
// If the room version doesn't allow restricted joins then don't
// try to process any further.
allowRestrictedJoins, err := roomInfo.RoomVersion.MayAllowRestrictedJoinsInEventAuth()
if err != nil {
return fmt.Errorf("roomInfo.RoomVersion.AllowRestrictedJoinsInEventAuth: %w", err)
} else if !allowRestrictedJoins {
allowRestrictedJoins := verImpl.MayAllowRestrictedJoinsInEventAuth()
if !allowRestrictedJoins {
return nil
}
// Start off by populating the "resident" flag in the response. If we

View file

@ -54,7 +54,7 @@ func (db *getEventDB) addFakeEvent(eventID string, authIDs []string) error {
return err
}
event, err := gomatrixserverlib.RoomVersionV1.NewEventFromTrustedJSON(
event, err := gomatrixserverlib.MustGetRoomVersion(gomatrixserverlib.RoomVersionV1).NewEventFromTrustedJSON(
eventJSON, false,
)
if err != nil {