sendToGroup: 404 from multi_recipient endpoint now treated differently
This commit is contained in:
		
					parent
					
						
							
								b37be94cb9
							
						
					
				
			
			
				commit
				
					
						4a3ffe07e8
					
				
			
		
					 2 changed files with 14 additions and 1 deletions
				
			
		| 
						 | 
					@ -303,4 +303,6 @@ export class UnregisteredUserError extends Error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class ConnectTimeoutError extends Error {}
 | 
					export class ConnectTimeoutError extends Error {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export class UnknownRecipientError extends Error {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class WarnOnlyError extends Error {}
 | 
					export class WarnOnlyError extends Error {}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,6 +36,7 @@ import {
 | 
				
			||||||
  ConnectTimeoutError,
 | 
					  ConnectTimeoutError,
 | 
				
			||||||
  OutgoingIdentityKeyError,
 | 
					  OutgoingIdentityKeyError,
 | 
				
			||||||
  SendMessageProtoError,
 | 
					  SendMessageProtoError,
 | 
				
			||||||
 | 
					  UnknownRecipientError,
 | 
				
			||||||
  UnregisteredUserError,
 | 
					  UnregisteredUserError,
 | 
				
			||||||
} from '../textsecure/Errors';
 | 
					} from '../textsecure/Errors';
 | 
				
			||||||
import type { HTTPError } from '../textsecure/Errors';
 | 
					import type { HTTPError } from '../textsecure/Errors';
 | 
				
			||||||
| 
						 | 
					@ -63,6 +64,7 @@ import * as log from '../logging/log';
 | 
				
			||||||
import { GLOBAL_ZONE } from '../SignalProtocolStore';
 | 
					import { GLOBAL_ZONE } from '../SignalProtocolStore';
 | 
				
			||||||
import { waitForAll } from './waitForAll';
 | 
					import { waitForAll } from './waitForAll';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const UNKNOWN_RECIPIENT = 404;
 | 
				
			||||||
const ERROR_EXPIRED_OR_MISSING_DEVICES = 409;
 | 
					const ERROR_EXPIRED_OR_MISSING_DEVICES = 409;
 | 
				
			||||||
const ERROR_STALE_DEVICES = 410;
 | 
					const ERROR_STALE_DEVICES = 410;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -564,6 +566,10 @@ export async function sendToGroupViaSenderKey(options: {
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  } catch (error) {
 | 
					  } catch (error) {
 | 
				
			||||||
 | 
					    if (error.code === UNKNOWN_RECIPIENT) {
 | 
				
			||||||
 | 
					      throw new UnknownRecipientError();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (error.code === ERROR_EXPIRED_OR_MISSING_DEVICES) {
 | 
					    if (error.code === ERROR_EXPIRED_OR_MISSING_DEVICES) {
 | 
				
			||||||
      await handle409Response(logId, error);
 | 
					      await handle409Response(logId, error);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -758,6 +764,11 @@ 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
 | 
				
			||||||
 | 
					  if (error instanceof UnknownRecipientError) {
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (
 | 
					  if (
 | 
				
			||||||
    error instanceof LibSignalErrorBase &&
 | 
					    error instanceof LibSignalErrorBase &&
 | 
				
			||||||
    error.code === ErrorCode.UntrustedIdentity
 | 
					    error.code === ErrorCode.UntrustedIdentity
 | 
				
			||||||
| 
						 | 
					@ -794,7 +805,7 @@ export function _shouldFailSend(error: unknown, logId: string): boolean {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (error.code === 404) {
 | 
					    if (error.code === 404) {
 | 
				
			||||||
      logError('Missing user or endpoint error, failing.');
 | 
					      logError('Failed to fetch metadata before send, failing.');
 | 
				
			||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue