From 649b22768e25c96237e73ac2817ec186cbe191ad Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 5 Feb 2020 11:56:03 +0000 Subject: [PATCH] Define newer room versions --- roomserver/version/version.go | 56 +++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/roomserver/version/version.go b/roomserver/version/version.go index afb28a056..6c726991f 100644 --- a/roomserver/version/version.go +++ b/roomserver/version/version.go @@ -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 }