sendToGroup: Don't fail send if we get 401 from multi_recipient/ request

This commit is contained in:
Scott Nonnenberg 2023-01-20 16:50:34 -08:00 committed by GitHub
parent b5947e0ef1
commit 7c1f186c05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 1 deletions

View file

@ -34,6 +34,7 @@ import type {
} from '../textsecure/SendMessage';
import {
ConnectTimeoutError,
IncorrectSenderKeyAuthError,
OutgoingIdentityKeyError,
SendMessageProtoError,
UnknownRecipientError,
@ -65,6 +66,7 @@ import { GLOBAL_ZONE } from '../SignalProtocolStore';
import { waitForAll } from './waitForAll';
const UNKNOWN_RECIPIENT = 404;
const INCORRECT_AUTH_KEY = 401;
const ERROR_EXPIRED_OR_MISSING_DEVICES = 409;
const ERROR_STALE_DEVICES = 410;
@ -569,6 +571,9 @@ export async function sendToGroupViaSenderKey(options: {
if (error.code === UNKNOWN_RECIPIENT) {
throw new UnknownRecipientError();
}
if (error.code === INCORRECT_AUTH_KEY) {
throw new IncorrectSenderKeyAuthError();
}
if (error.code === ERROR_EXPIRED_OR_MISSING_DEVICES) {
await handle409Response(logId, error);
@ -764,10 +769,13 @@ export function _shouldFailSend(error: unknown, logId: string): boolean {
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) {
return false;
}
if (error instanceof IncorrectSenderKeyAuthError) {
return false;
}
if (
error instanceof LibSignalErrorBase &&