Consider group send a failure if sending to any member in the group fails.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-04-12 17:40:36 -04:00
parent 1023eeb8a0
commit db051b3b3e
1 changed files with 5 additions and 19 deletions

View File

@ -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);
}
}
}