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 'AxolotlKit', git: 'https://github.com/WhisperSystems/SignalProtocolKit.git'
#pod 'AxolotlKit', path: '../SignalProtocolKit'
pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
#pod 'SignalServiceKit', path: '../SignalServiceKit'
#pod 'SignalServiceKit', git: 'https://github.com/WhisperSystems/SignalServiceKit.git'
pod 'SignalServiceKit', path: '../SignalServiceKit'
pod 'OpenSSL'
pod 'JSQMessagesViewController', git: 'https://github.com/WhisperSystems/JSQMessagesViewController.git', branch: 'mkirk/position-edit-menu'
#pod 'JSQMessagesViewController' path: '../JSQMessagesViewController'

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

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

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

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

Loading…
Cancel
Save