mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-18 23:49:20 +01:00
Handle new rate limiting info from CDSI
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user