Define newer room versions

This commit is contained in:
Neil Alexander 2020-02-05 11:56:03 +00:00
parent 2c561f7122
commit 649b22768e

View file

@ -7,24 +7,70 @@ import (
) )
type RoomVersionID int type RoomVersionID int
type EventFormatID int
const ( const (
RoomVersionV1 RoomVersionID = iota + 1 RoomVersionV1 RoomVersionID = iota + 1
RoomVersionV2
RoomVersionV3
RoomVersionV4
RoomVersionV5
)
const (
EventFormatV1 EventFormatID = iota + 1
EventFormatV2
EventFormatV3
) )
type RoomVersionDescription struct { type RoomVersionDescription struct {
Supported bool
Stable bool Stable bool
StateResolution state.StateResolutionVersion StateResolution state.StateResolutionVersion
EventFormat EventFormatID
} }
func GetRoomVersionDescription(version RoomVersionID) (RoomVersionDescription, error) { func GetRoomVersionDescription(version RoomVersionID) (desc RoomVersionDescription, err error) {
switch version { switch version {
case RoomVersionV1: case RoomVersionV1:
return RoomVersionDescription{ desc = RoomVersionDescription{
Supported: true,
Stable: true, Stable: true,
StateResolution: state.StateResolutionV1, StateResolution: state.StateResolutionAlgorithmV1,
}, nil EventFormat: EventFormatV1,
}
case RoomVersionV2:
desc = RoomVersionDescription{
Supported: false,
Stable: true,
StateResolution: state.StateResolutionAlgorithmV2,
EventFormat: EventFormatV1,
}
case RoomVersionV3:
desc = RoomVersionDescription{
Supported: false,
Stable: true,
StateResolution: state.StateResolutionAlgorithmV2,
EventFormat: EventFormatV1,
}
case RoomVersionV4:
desc = RoomVersionDescription{
Supported: false,
Stable: true,
StateResolution: state.StateResolutionAlgorithmV2,
EventFormat: EventFormatV2,
}
case RoomVersionV5:
desc = RoomVersionDescription{
Supported: false,
Stable: true,
StateResolution: state.StateResolutionAlgorithmV2,
EventFormat: EventFormatV3,
}
default: default:
return nil, errors.New("unsupported room version")
} }
if !desc.Supported {
err = errors.New("unsupported room version")
}
return
} }