diff --git a/src/Internal/Api/GetEvent/Api.elm b/src/Internal/Api/GetEvent/Api.elm index b611ca1..5b7904f 100644 --- a/src/Internal/Api/GetEvent/Api.elm +++ b/src/Internal/Api/GetEvent/Api.elm @@ -19,6 +19,18 @@ type alias GetEventOutputV1 = getEventInputV1 : GetEventInputV1 -> Context { a | accessToken : (), baseUrl : (), sentEvent : () } -> Task X.Error GetEventOutputV1 getEventInputV1 data context = + context + |> R.callApi "GET" "/_matrix/client/r0/rooms/{roomId}/event/{eventId}" + |> R.withAttributes + [ R.accessToken + , R.replaceInUrl "eventId" (Context.getSentEvent context) + , R.replaceInUrl "roomId" data.roomId + , R.onStatusCode 404 (X.M_NOT_FOUND { error = Just SE.eventNotFound }) + ] + |> R.toTask SO1.clientEventDecoder + +getEventInputV2 : GetEventInputV1 -> Context { a | accessToken : (), baseUrl : (), sentEvent : () } -> Task X.Error GetEventOutputV1 +getEventInputV2 data context = context |> R.callApi "GET" "/_matrix/client/v3/rooms/{roomId}/event/{eventId}" |> R.withAttributes diff --git a/src/Internal/Api/GetEvent/Main.elm b/src/Internal/Api/GetEvent/Main.elm index 400332e..7c51253 100644 --- a/src/Internal/Api/GetEvent/Main.elm +++ b/src/Internal/Api/GetEvent/Main.elm @@ -15,12 +15,19 @@ getEvent context input = } |> VC.sameForVersion "r0.6.0" |> VC.sameForVersion "r0.6.1" - |> VC.sameForVersion "v1.1" + |> VC.addMiddleLayer + { downcast = identity + , current = Api.getEventInputV2 + , upcast = identity + , version = "v1.1" + } |> VC.sameForVersion "v1.2" |> VC.sameForVersion "v1.3" |> VC.sameForVersion "v1.4" |> VC.sameForVersion "v1.5" |> VC.sameForVersion "v1.6" + |> VC.sameForVersion "v1.7" + |> VC.sameForVersion "v1.8" |> VC.mostRecentFromVersionList (Context.getVersions context) |> Maybe.withDefault (always <| always <| Task.fail X.UnsupportedSpecVersion) |> (|>) input diff --git a/src/Internal/Api/README.md b/src/Internal/Api/README.md index 602c721..84ef984 100644 --- a/src/Internal/Api/README.md +++ b/src/Internal/Api/README.md @@ -64,8 +64,8 @@ Note that **under development** doesn't always mean that it _will be_ supported. | **Spec version** | | Event | Joined members | Event at timestamp | | ---------------- | - | ----- | -------------- | ------------------ | -| v1.8 || ⚡ | ⚡ | ⚡ | -| v1.7 || ⚡ | ⚡ | ⚡ | +| v1.8 || ✔️ | ⚡ | ⚡ | +| v1.7 || ✔️ | ⚡ | ⚡ | | v1.6 || ✔️ | ✔️ | ⚠️ | | v1.5 || ✔️ | ✔️ | ⛔ | | v1.4 || ✔️ | ✔️ | ⛔ |