mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 20:03:10 -06:00
Define newer room versions
This commit is contained in:
parent
2c561f7122
commit
649b22768e
|
|
@ -7,24 +7,70 @@ import (
|
|||
)
|
||||
|
||||
type RoomVersionID int
|
||||
type EventFormatID int
|
||||
|
||||
const (
|
||||
RoomVersionV1 RoomVersionID = iota + 1
|
||||
RoomVersionV2
|
||||
RoomVersionV3
|
||||
RoomVersionV4
|
||||
RoomVersionV5
|
||||
)
|
||||
|
||||
const (
|
||||
EventFormatV1 EventFormatID = iota + 1
|
||||
EventFormatV2
|
||||
EventFormatV3
|
||||
)
|
||||
|
||||
type RoomVersionDescription struct {
|
||||
Supported bool
|
||||
Stable bool
|
||||
StateResolution state.StateResolutionVersion
|
||||
EventFormat EventFormatID
|
||||
}
|
||||
|
||||
func GetRoomVersionDescription(version RoomVersionID) (RoomVersionDescription, error) {
|
||||
func GetRoomVersionDescription(version RoomVersionID) (desc RoomVersionDescription, err error) {
|
||||
switch version {
|
||||
case RoomVersionV1:
|
||||
return RoomVersionDescription{
|
||||
desc = RoomVersionDescription{
|
||||
Supported: true,
|
||||
Stable: true,
|
||||
StateResolution: state.StateResolutionV1,
|
||||
}, nil
|
||||
StateResolution: state.StateResolutionAlgorithmV1,
|
||||
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:
|
||||
return nil, errors.New("unsupported room version")
|
||||
}
|
||||
if !desc.Supported {
|
||||
err = errors.New("unsupported room version")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue