Improve handling of group creation failures.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent f4a77f730f
commit 6f1f1fac80

@ -5,8 +5,8 @@ target 'Signal' do
pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git' pod 'SocketRocket', :git => 'https://github.com/facebook/SocketRocket.git'
pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git' pod 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
#pod 'AxolotlKit', path: '../SignalProtocolKit' #pod 'AxolotlKit', path: '../SignalProtocolKit'
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git' #pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
#pod 'SignalServiceKit', path: '../SignalServiceKit' pod 'SignalServiceKit', path: '../SignalServiceKit'
pod 'OpenSSL' pod 'OpenSSL'
pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu' pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu'
#pod 'JSQMessagesViewController' path: '../JSQMessagesViewController' #pod 'JSQMessagesViewController' path: '../JSQMessagesViewController'

@ -114,7 +114,7 @@ DEPENDENCIES:
- OpenSSL - OpenSSL
- PureLayout - PureLayout
- Reachability - Reachability
- SignalServiceKit (from `https://github.com/WhisperSystems/SignalServiceKit.git`) - SignalServiceKit (from `../SignalServiceKit`)
- SocketRocket (from `https://github.com/facebook/SocketRocket.git`) - SocketRocket (from `https://github.com/facebook/SocketRocket.git`)
EXTERNAL SOURCES: EXTERNAL SOURCES:
@ -124,7 +124,7 @@ EXTERNAL SOURCES:
:branch: mkirk/position-edit-menu :branch: mkirk/position-edit-menu
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git :git: https://github.com/WhisperSystems/JSQMessagesViewController.git
SignalServiceKit: SignalServiceKit:
:git: https://github.com/WhisperSystems/SignalServiceKit.git :path: ../SignalServiceKit
SocketRocket: SocketRocket:
:git: https://github.com/facebook/SocketRocket.git :git: https://github.com/facebook/SocketRocket.git
@ -135,9 +135,6 @@ CHECKOUT OPTIONS:
JSQMessagesViewController: JSQMessagesViewController:
:commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308
:git: https://github.com/WhisperSystems/JSQMessagesViewController.git :git: https://github.com/WhisperSystems/JSQMessagesViewController.git
SignalServiceKit:
:commit: 7052b97c72c7d9601883c55ba8ad6a5729b8f504
:git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket: SocketRocket:
:commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf
:git: https://github.com/facebook/SocketRocket.git :git: https://github.com/facebook/SocketRocket.git
@ -164,6 +161,6 @@ SPEC CHECKSUMS:
UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d UnionFind: c33be5adb12983981d6e827ea94fc7f9e370f52d
YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266 YapDatabase: cd911121580ff16675f65ad742a9eb0ab4d9e266
PODFILE CHECKSUM: 48e80d7f1e049bbf544a689fdfdf33e8196c640a PODFILE CHECKSUM: 6f9ef5d9fa17469569e127a9f5719dafa11631b9
COCOAPODS: 1.2.1 COCOAPODS: 1.2.1

@ -2388,6 +2388,9 @@ typedef enum : NSUInteger {
OWSAssert([message isKindOfClass:[OWSUnknownContactBlockOfferMessage class]]); OWSAssert([message isKindOfClass:[OWSUnknownContactBlockOfferMessage class]]);
[self tappedUnknownContactBlockOfferMessage:(OWSUnknownContactBlockOfferMessage *)message]; [self tappedUnknownContactBlockOfferMessage:(OWSUnknownContactBlockOfferMessage *)message];
return; return;
case TSErrorMessageGroupCreationFailed:
[self resendGroupUpdateForErrorMessage:message];
return;
} }
DDLogWarn(@"%@ Unhandled tap for error message:%@", self.tag, message); DDLogWarn(@"%@ Unhandled tap for error message:%@", self.tag, message);
@ -3660,7 +3663,7 @@ typedef enum : NSUInteger {
[messageData performEditingAction:action]; [messageData performEditingAction:action];
} }
- (void)updateGroupModelTo:(TSGroupModel *)newGroupModel - (void)updateGroupModelTo:(TSGroupModel *)newGroupModel successCompletion:(void (^_Nullable)())successCompletion
{ {
__block TSGroupThread *groupThread; __block TSGroupThread *groupThread;
__block TSOutgoingMessage *message; __block TSOutgoingMessage *message;
@ -3686,6 +3689,9 @@ typedef enum : NSUInteger {
inMessage:message inMessage:message
success:^{ success:^{
DDLogDebug(@"%@ Successfully sent group update with avatar", self.tag); DDLogDebug(@"%@ Successfully sent group update with avatar", self.tag);
if (successCompletion) {
successCompletion();
}
} }
failure:^(NSError *_Nonnull error) { failure:^(NSError *_Nonnull error) {
DDLogError(@"%@ Failed to send group avatar update with error: %@", self.tag, error); DDLogError(@"%@ Failed to send group avatar update with error: %@", self.tag, error);
@ -3694,6 +3700,9 @@ typedef enum : NSUInteger {
[self.messageSender sendMessage:message [self.messageSender sendMessage:message
success:^{ success:^{
DDLogDebug(@"%@ Successfully sent group update", self.tag); DDLogDebug(@"%@ Successfully sent group update", self.tag);
if (successCompletion) {
successCompletion();
}
} }
failure:^(NSError *_Nonnull error) { failure:^(NSError *_Nonnull error) {
DDLogError(@"%@ Failed to send group update with error: %@", self.tag, error); DDLogError(@"%@ Failed to send group update with error: %@", self.tag, error);
@ -4014,6 +4023,22 @@ typedef enum : NSUInteger {
#pragma mark - OWSConversationSettingsViewDelegate #pragma mark - OWSConversationSettingsViewDelegate
- (void)resendGroupUpdateForErrorMessage:(TSErrorMessage *)message
{
OWSAssert([NSThread isMainThread]);
OWSAssert([_thread isKindOfClass:[TSGroupThread class]]);
OWSAssert(message);
TSGroupThread *groupThread = (TSGroupThread *)self.thread;
TSGroupModel *groupModel = groupThread.groupModel;
[self updateGroupModelTo:groupModel
successCompletion:^{
DDLogInfo(@"Group updated, removing group creation error.");
[message remove];
}];
}
- (void)groupWasUpdated:(TSGroupModel *)groupModel - (void)groupWasUpdated:(TSGroupModel *)groupModel
{ {
OWSAssert(groupModel); OWSAssert(groupModel);
@ -4021,7 +4046,7 @@ typedef enum : NSUInteger {
NSMutableSet *groupMemberIds = [NSMutableSet setWithArray:groupModel.groupMemberIds]; NSMutableSet *groupMemberIds = [NSMutableSet setWithArray:groupModel.groupMemberIds];
[groupMemberIds addObject:[TSAccountManager localNumber]]; [groupMemberIds addObject:[TSAccountManager localNumber]];
groupModel.groupMemberIds = [NSMutableArray arrayWithArray:[groupMemberIds allObjects]]; groupModel.groupMemberIds = [NSMutableArray arrayWithArray:[groupMemberIds allObjects]];
[self updateGroupModelTo:groupModel]; [self updateGroupModelTo:groupModel successCompletion:nil];
[self.collectionView.collectionViewLayout [self.collectionView.collectionViewLayout
invalidateLayoutWithContext:[JSQMessagesCollectionViewFlowLayoutInvalidationContext context]]; invalidateLayoutWithContext:[JSQMessagesCollectionViewFlowLayoutInvalidationContext context]];
[self.collectionView reloadData]; [self.collectionView reloadData];

@ -450,26 +450,33 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
}]; }];
OWSAssert(thread); OWSAssert(thread);
void (^popToThread)() = ^{ void (^successHandler)() = ^{
DDLogError(@"Group creation successful.");
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
// Pop to new group thread.
[Environment messageGroup:thread]; [Environment messageGroup:thread];
}]; }];
}); });
}; };
void (^removeThreadWithError)(NSError *error) = ^(NSError *error) { void (^failureHandler)(NSError *error) = ^(NSError *error) {
[thread remove]; DDLogError(@"Group creation failed: %@", error);
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
[OWSAlerts // Add an error message to the new group indicating
showAlertWithTitle: // that group creation didn't succeed.
NSLocalizedString(@"GROUP_CREATING_FAILED", [[[TSErrorMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
"Title of alert indicating that new group could not be created.") inThread:thread
message:error.localizedDescription]; failedMessageType:TSErrorMessageGroupCreationFailed]
save];
[Environment messageGroup:thread];
}]; }];
}); });
}; };
@ -489,15 +496,16 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
// This will save the message. // This will save the message.
[message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)]; [message updateWithCustomMessage:NSLocalizedString(@"GROUP_CREATED", nil)];
if (model.groupImage) { if (model.groupImage) {
[self.messageSender sendAttachmentData:UIImagePNGRepresentation(model.groupImage) [self.messageSender sendAttachmentData:UIImagePNGRepresentation(model.groupImage)
contentType:OWSMimeTypeImagePng contentType:OWSMimeTypeImagePng
sourceFilename:nil sourceFilename:nil
inMessage:message inMessage:message
success:popToThread success:successHandler
failure:removeThreadWithError]; failure:failureHandler];
} else { } else {
[self.messageSender sendMessage:message success:popToThread failure:removeThreadWithError]; [self.messageSender sendMessage:message success:successHandler failure:failureHandler];
} }
}]; }];
} }

@ -124,6 +124,7 @@ NS_ASSUME_NONNULL_BEGIN
case TSErrorMessageDuplicateMessage: case TSErrorMessageDuplicateMessage:
case TSErrorMessageInvalidVersion: case TSErrorMessageInvalidVersion:
case TSErrorMessageUnknownContactBlockOffer: case TSErrorMessageUnknownContactBlockOffer:
case TSErrorMessageGroupCreationFailed:
result = [UIImage imageNamed:@"system_message_info"]; result = [UIImage imageNamed:@"system_message_info"];
break; break;
} }

@ -553,8 +553,8 @@
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"GROUP_CREATING" = "Creating new group"; "GROUP_CREATING" = "Creating new group";
/* Title of alert indicating that new group could not be created. */ /* Message shown in conversation view that indicates there were issues with group creation. */
"GROUP_CREATING_FAILED" = "Group creation failed"; "GROUP_CREATION_FAILED" = "Not all members could be added to the group. Tap to retry.";
/* Conversation settings table section title */ /* Conversation settings table section title */
"GROUP_MANAGEMENT_SECTION" = "Group Management"; "GROUP_MANAGEMENT_SECTION" = "Group Management";

Loading…
Cancel
Save