sendToGroup: Don't fail send if we get 401 from multi_recipient/ request
This commit is contained in:
parent
b5947e0ef1
commit
7c1f186c05
3 changed files with 23 additions and 1 deletions
|
@ -15,12 +15,14 @@ import type { DeviceType } from '../../textsecure/Types.d';
|
||||||
import {
|
import {
|
||||||
ConnectTimeoutError,
|
ConnectTimeoutError,
|
||||||
HTTPError,
|
HTTPError,
|
||||||
|
IncorrectSenderKeyAuthError,
|
||||||
MessageError,
|
MessageError,
|
||||||
OutgoingIdentityKeyError,
|
OutgoingIdentityKeyError,
|
||||||
OutgoingMessageError,
|
OutgoingMessageError,
|
||||||
SendMessageChallengeError,
|
SendMessageChallengeError,
|
||||||
SendMessageNetworkError,
|
SendMessageNetworkError,
|
||||||
SendMessageProtoError,
|
SendMessageProtoError,
|
||||||
|
UnknownRecipientError,
|
||||||
UnregisteredUserError,
|
UnregisteredUserError,
|
||||||
} from '../../textsecure/Errors';
|
} from '../../textsecure/Errors';
|
||||||
|
|
||||||
|
@ -219,6 +221,16 @@ describe('sendToGroup', () => {
|
||||||
assert.isFalse(_shouldFailSend(error, 'testing generic 204'));
|
assert.isFalse(_shouldFailSend(error, 'testing generic 204'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns false for specific errors', () => {
|
||||||
|
const unknownRecipient = new UnknownRecipientError();
|
||||||
|
assert.isFalse(
|
||||||
|
_shouldFailSend(unknownRecipient, 'testing unknown recipient')
|
||||||
|
);
|
||||||
|
|
||||||
|
const incorrectAuth = new IncorrectSenderKeyAuthError();
|
||||||
|
assert.isFalse(_shouldFailSend(incorrectAuth, 'testing incorrect auth'));
|
||||||
|
});
|
||||||
|
|
||||||
it('returns true for a specified error codes', () => {
|
it('returns true for a specified error codes', () => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const error: any = new Error('generic');
|
const error: any = new Error('generic');
|
||||||
|
|
|
@ -305,4 +305,6 @@ export class ConnectTimeoutError extends Error {}
|
||||||
|
|
||||||
export class UnknownRecipientError extends Error {}
|
export class UnknownRecipientError extends Error {}
|
||||||
|
|
||||||
|
export class IncorrectSenderKeyAuthError extends Error {}
|
||||||
|
|
||||||
export class WarnOnlyError extends Error {}
|
export class WarnOnlyError extends Error {}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import type {
|
||||||
} from '../textsecure/SendMessage';
|
} from '../textsecure/SendMessage';
|
||||||
import {
|
import {
|
||||||
ConnectTimeoutError,
|
ConnectTimeoutError,
|
||||||
|
IncorrectSenderKeyAuthError,
|
||||||
OutgoingIdentityKeyError,
|
OutgoingIdentityKeyError,
|
||||||
SendMessageProtoError,
|
SendMessageProtoError,
|
||||||
UnknownRecipientError,
|
UnknownRecipientError,
|
||||||
|
@ -65,6 +66,7 @@ import { GLOBAL_ZONE } from '../SignalProtocolStore';
|
||||||
import { waitForAll } from './waitForAll';
|
import { waitForAll } from './waitForAll';
|
||||||
|
|
||||||
const UNKNOWN_RECIPIENT = 404;
|
const UNKNOWN_RECIPIENT = 404;
|
||||||
|
const INCORRECT_AUTH_KEY = 401;
|
||||||
const ERROR_EXPIRED_OR_MISSING_DEVICES = 409;
|
const ERROR_EXPIRED_OR_MISSING_DEVICES = 409;
|
||||||
const ERROR_STALE_DEVICES = 410;
|
const ERROR_STALE_DEVICES = 410;
|
||||||
|
|
||||||
|
@ -569,6 +571,9 @@ export async function sendToGroupViaSenderKey(options: {
|
||||||
if (error.code === UNKNOWN_RECIPIENT) {
|
if (error.code === UNKNOWN_RECIPIENT) {
|
||||||
throw new UnknownRecipientError();
|
throw new UnknownRecipientError();
|
||||||
}
|
}
|
||||||
|
if (error.code === INCORRECT_AUTH_KEY) {
|
||||||
|
throw new IncorrectSenderKeyAuthError();
|
||||||
|
}
|
||||||
|
|
||||||
if (error.code === ERROR_EXPIRED_OR_MISSING_DEVICES) {
|
if (error.code === ERROR_EXPIRED_OR_MISSING_DEVICES) {
|
||||||
await handle409Response(logId, error);
|
await handle409Response(logId, error);
|
||||||
|
@ -764,10 +769,13 @@ export function _shouldFailSend(error: unknown, logId: string): boolean {
|
||||||
log.error(`_shouldFailSend/${logId}: ${message}`);
|
log.error(`_shouldFailSend/${logId}: ${message}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
// We need to fail over to a normal send if multi_recipient/ endpoint returns 404
|
// We need to fail over to a normal send if multi_recipient/ endpoint returns 404 or 401
|
||||||
if (error instanceof UnknownRecipientError) {
|
if (error instanceof UnknownRecipientError) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (error instanceof IncorrectSenderKeyAuthError) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
error instanceof LibSignalErrorBase &&
|
error instanceof LibSignalErrorBase &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue