Handle new rate limiting info from CDSI
This commit is contained in:
parent
b26f60d2fc
commit
f0a3735ca2
4 changed files with 51 additions and 36 deletions
23
ts/textsecure/cds/RateLimitedError.ts
Normal file
23
ts/textsecure/cds/RateLimitedError.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
export type RateLimitedErrorPayloadType = Readonly<{
|
||||
// eslint-disable-next-line camelcase
|
||||
retry_after?: number;
|
||||
}>;
|
||||
|
||||
export class RateLimitedError extends Error {
|
||||
public readonly retryAfterSecs: number;
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
constructor({ retry_after }: RateLimitedErrorPayloadType) {
|
||||
super(
|
||||
'RateLimitedError: got 4008 close code from CDSI, ' +
|
||||
// eslint-disable-next-line camelcase
|
||||
`retry_after=${retry_after}`
|
||||
);
|
||||
|
||||
// eslint-disable-next-line camelcase
|
||||
this.retryAfterSecs = retry_after ?? 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue