From db051b3b3e9531e855b56b99e6f7f8d274d367ff Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 12 Apr 2017 17:40:36 -0400 Subject: [PATCH] Consider group send a failure if sending to any member in the group fails. // FREEBIE --- src/Messages/OWSMessageSender.m | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Messages/OWSMessageSender.m b/src/Messages/OWSMessageSender.m index 41275219f..9c90e9fff 100644 --- a/src/Messages/OWSMessageSender.m +++ b/src/Messages/OWSMessageSender.m @@ -682,26 +682,12 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; [completionFuture catchDo:^(id failure) { // failure from toc_thenAll yeilds an array of failed Futures, rather than the future's failure. if ([failure isKindOfClass:[NSArray class]]) { - NSArray *errors = (NSArray *)failure; - for (TOCFuture *failedFuture in errors) { - if (!failedFuture.hasFailed) { - // If at least one send succeeded, don't show message as failed. - // Else user will tap-to-resend to all recipients, including those that already received the - // message. - return successHandler(); - } - } - - // At this point, all recipients must have failed. - // But we have all this verbose type checking because TOCFuture doesn't expose type information. - id lastError = errors.lastObject; - if ([lastError isKindOfClass:[TOCFuture class]]) { - TOCFuture *failedFuture = (TOCFuture *)lastError; - if (failedFuture.hasFailed) { - id failureResult = failedFuture.forceGetFailure; + NSArray *groupSendFutures = (NSArray *)failure; + for (TOCFuture *groupSendFuture in groupSendFutures) { + if (groupSendFuture.hasFailed) { + id failureResult = groupSendFuture.forceGetFailure; if ([failureResult isKindOfClass:[NSError class]]) { - // Generally we assume that failures are retryable - return failureHandler((NSError *)failureResult, YES); + return failureHandler(failureResult, YES); } } }