Skip to content

Prefer stable /timestamp_to_event endpoint first - MSC3030 #2915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3a18976
Prefer stable endpoint first
MadLittleMods Nov 29, 2022
d3f08fe
Add tests
MadLittleMods Dec 1, 2022
d1ede03
Add return type
MadLittleMods Dec 1, 2022
9a731cd
Add some comments
MadLittleMods Dec 1, 2022
ad8bb5d
Fix lints
MadLittleMods Dec 1, 2022
9a98e80
Fix relevant strict ts error
MadLittleMods Dec 1, 2022
bf78a64
Remove console coloring in favor of future PR
MadLittleMods Dec 8, 2022
c953fc9
Update casing
MadLittleMods Dec 8, 2022
ed91bd9
Merge branch 'develop' into madlittlemods/stablize-msc3030-timestamp-…
MadLittleMods Dec 9, 2022
9841f92
Fix some eslint
MadLittleMods Dec 9, 2022
fcf12b4
Merge branch 'develop' into madlittlemods/stablize-msc3030-timestamp-…
MadLittleMods Dec 13, 2022
70a033c
Prettier fixes
MadLittleMods Dec 13, 2022
a0aa507
Fix prefix lint
MadLittleMods Dec 13, 2022
4683fbe
Merge branch 'develop' into madlittlemods/stablize-msc3030-timestamp-…
MadLittleMods Dec 16, 2022
ca98d9f
Tests for convertQueryDictToStringRecord
andybalaam Jan 6, 2023
b1566ee
Switch to a Map for convertQueryDictToStringRecord
andybalaam Jan 6, 2023
d744214
Rename convertQueryDictToMap
andybalaam Jan 6, 2023
c4ca0b2
Refactor timestampToEvent tests
andybalaam Jan 6, 2023
628bcbf
Fall back to the unstable endpoint if we receive a 405 status
andybalaam Jan 6, 2023
12cc7be
Test 400, 429 and 502 responses
andybalaam Jan 6, 2023
f00f70b
Merge branch 'develop' into madlittlemods/stablize-msc3030-timestamp-…
andybalaam Jan 6, 2023
981acf0
Rename test to fit renamed function.
andybalaam Jan 6, 2023
c7c1625
Update comment to reflect commonality between 404 and 405 status
andybalaam Jan 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion spec/unit/matrix-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ describe("MatrixClient", function () {
]);
});

it("should fallback to unstable endpoint when no support for stable endpoint", async () => {
it("should fallback to unstable endpoint when stable endpoint 404s", async () => {
await assertRequestsMade([
{
prefix: ClientPrefix.V1,
Expand All @@ -433,6 +433,22 @@ describe("MatrixClient", function () {
]);
});

it("should fallback to unstable endpoint when stable endpoint 405s", async () => {
await assertRequestsMade([
{
prefix: ClientPrefix.V1,
error: {
httpStatus: 405,
errcode: "M_UNRECOGNIZED",
},
},
{
prefix: unstableMSC3030Prefix,
data: { event_id: eventId },
},
]);
});

it("should not fallback to unstable endpoint when stable endpoint returns an error", async () => {
await assertRequestsMade(
[
Expand Down
5 changes: 4 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9391,7 +9391,10 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
((<MatrixError>err).httpStatus === 400 ||
// This the correct standard status code for an unsupported
// endpoint according to MSC3743.
(<MatrixError>err).httpStatus === 404)
(<MatrixError>err).httpStatus === 404 ||
// This the correct standard status code for an invalid
// method according to MSC3743.
(<MatrixError>err).httpStatus === 405)
) {
return await this.http.authedRequest(Method.Get, path, queryParams, undefined, {
prefix: "/_matrix/client/unstable/org.matrix.msc3030",
Expand Down