Introduce Service Id Types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:

committed by
Jamie Kyle

parent
414c0a58d3
commit
366b875fd2
@@ -6,6 +6,7 @@
|
||||
import type { LibSignalErrorBase } from '@signalapp/libsignal-client';
|
||||
|
||||
import { parseRetryAfter } from '../util/parseRetryAfter';
|
||||
import type { ServiceIdString } from '../types/ServiceId';
|
||||
|
||||
import type { CallbackResultType } from './Types.d';
|
||||
import type { HeaderListType } from './WebAPI';
|
||||
@@ -191,13 +192,13 @@ export class SendMessageChallengeError extends ReplayableError {
|
||||
}
|
||||
|
||||
export class SendMessageProtoError extends Error implements CallbackResultType {
|
||||
public readonly successfulIdentifiers?: Array<string>;
|
||||
public readonly successfulServiceIds?: Array<ServiceIdString>;
|
||||
|
||||
public readonly failoverIdentifiers?: Array<string>;
|
||||
public readonly failoverServiceIds?: Array<ServiceIdString>;
|
||||
|
||||
public readonly errors?: CallbackResultType['errors'];
|
||||
|
||||
public readonly unidentifiedDeliveries?: Array<string>;
|
||||
public readonly unidentifiedDeliveries?: Array<ServiceIdString>;
|
||||
|
||||
public readonly dataMessage: Uint8Array | undefined;
|
||||
|
||||
@@ -210,13 +211,13 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
||||
|
||||
public readonly timestamp?: number;
|
||||
|
||||
public readonly recipients?: Record<string, Array<number>>;
|
||||
public readonly recipients?: Record<ServiceIdString, Array<number>>;
|
||||
|
||||
public readonly sendIsNotFinal?: boolean;
|
||||
|
||||
constructor({
|
||||
successfulIdentifiers,
|
||||
failoverIdentifiers,
|
||||
successfulServiceIds,
|
||||
failoverServiceIds,
|
||||
errors,
|
||||
unidentifiedDeliveries,
|
||||
dataMessage,
|
||||
@@ -229,8 +230,8 @@ export class SendMessageProtoError extends Error implements CallbackResultType {
|
||||
}: CallbackResultType) {
|
||||
super(`SendMessageProtoError: ${SendMessageProtoError.getMessage(errors)}`);
|
||||
|
||||
this.successfulIdentifiers = successfulIdentifiers;
|
||||
this.failoverIdentifiers = failoverIdentifiers;
|
||||
this.successfulServiceIds = successfulServiceIds;
|
||||
this.failoverServiceIds = failoverServiceIds;
|
||||
this.errors = errors;
|
||||
this.unidentifiedDeliveries = unidentifiedDeliveries;
|
||||
this.dataMessage = dataMessage;
|
||||
@@ -271,11 +272,11 @@ export class MessageError extends ReplayableError {
|
||||
}
|
||||
|
||||
export class UnregisteredUserError extends Error {
|
||||
readonly identifier: string;
|
||||
readonly serviceId: string;
|
||||
|
||||
readonly httpError: HTTPError;
|
||||
|
||||
constructor(identifier: string, httpError: HTTPError) {
|
||||
constructor(serviceId: ServiceIdString, httpError: HTTPError) {
|
||||
const { message } = httpError;
|
||||
|
||||
super(message);
|
||||
@@ -289,7 +290,7 @@ export class UnregisteredUserError extends Error {
|
||||
Error.captureStackTrace(this);
|
||||
}
|
||||
|
||||
this.identifier = identifier;
|
||||
this.serviceId = serviceId;
|
||||
this.httpError = httpError;
|
||||
|
||||
appendStack(this, httpError);
|
||||
|
Reference in New Issue
Block a user