Skip to content

Commit 518ea18

Browse files
committed
Fix message host resolution
Following an API change, Skype returns a 404 error instead of 301 when the message host is invalid. This caused an UnexpectedHttpStatus error (removed by this commit). See #73 (comment)
1 parent 10b98a7 commit 518ea18

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Next
22

33
- **[Fix]** Do not throw on unexpected extra keys when reading responses.
4+
- **[Fix]** Fix message host resolution (API change).
45

56
# 0.0.14 (2018-01-12)
67

src/lib/helpers/register-endpoint.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ export async function registerEndpoint(
9393
throw new EndpointRegistrationError(LoginRateLimitExceeded.create(req, res), tries);
9494
}
9595

96-
const expectedStatusCode: Set<number> = new Set([201, 301]);
96+
// TODO: Check eventual changes in the API. I'm not sure if 301 is still used
97+
// 404 was seen the 2017-01-14, with the following body:
98+
// '{"errorCode":752,"message":"User is in a different cloud. See \'Location\' header for users current cloud."}'
99+
const expectedStatusCode: Set<number> = new Set([201, 301, 404]);
97100
if (!expectedStatusCode.has(res.statusCode)) {
98101
throw new EndpointRegistrationError(UnexpectedHttpStatusError.create(res, expectedStatusCode, req), tries);
99102
}
@@ -109,7 +112,9 @@ export async function registerEndpoint(
109112
throw new Incident("ParseError", {res}, "Expected `Location` header to have host");
110113
}
111114
// Handle redirections, up to `retry` times
112-
if (location.host !== messagesHostname) { // mainly when 301, but sometimes when 201
115+
// Redirections happen mostly when 301, but sometimes when 201
116+
// TODO: It may have changed to mostly 404.
117+
if (location.host !== messagesHostname) {
113118
messagesHostname = location.host;
114119
continue;
115120
}

0 commit comments

Comments
 (0)