Merge branch 'charlesmchen/profileNameLengthError'
This commit is contained in:
commit
428edb6172
|
@ -45,6 +45,8 @@ extern const NSUInteger kOWSProfileManager_MaxAvatarDiameter;
|
|||
success:(void (^)())successBlock
|
||||
failure:(void (^)())failureBlock;
|
||||
|
||||
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName;
|
||||
|
||||
#pragma mark - Profile Whitelist
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -850,11 +850,6 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
{
|
||||
OWSAssert(contactRecipientIds);
|
||||
|
||||
// TODO: The persisted whitelist could either be:
|
||||
//
|
||||
// * Just users manually added to the whitelist.
|
||||
// * Also include users auto-added by, for example, being in the user's
|
||||
// contacts or when the user initiates a 1:1 conversation with them, etc.
|
||||
[self addUsersToProfileWhitelist:contactRecipientIds];
|
||||
}
|
||||
|
||||
|
@ -1198,6 +1193,14 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
|
|||
return [self encryptProfileData:data profileKey:self.localProfileKey];
|
||||
}
|
||||
|
||||
- (BOOL)isProfileNameTooLong:(nullable NSString *)profileName
|
||||
{
|
||||
OWSAssert([NSThread isMainThread]);
|
||||
|
||||
NSData *nameData = [profileName dataUsingEncoding:NSUTF8StringEncoding];
|
||||
return nameData.length > kOWSProfileManager_NameDataLength;
|
||||
}
|
||||
|
||||
- (nullable NSData *)encryptProfileNameWithUnpaddedName:(NSString *)name
|
||||
{
|
||||
NSData *nameData = [name dataUsingEncoding:NSUTF8StringEncoding];
|
||||
|
|
|
@ -369,6 +369,15 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
|
|||
{
|
||||
__weak ProfileViewController *weakSelf = self;
|
||||
|
||||
NSString *normalizedProfileName = [self normalizedProfileName];
|
||||
if ([OWSProfileManager.sharedManager isProfileNameTooLong:normalizedProfileName]) {
|
||||
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"ALERT_ERROR_TITLE", @"")
|
||||
message:NSLocalizedString(@"PROFILE_VIEW_ERROR_PROFILE_NAME_TOO_LONG",
|
||||
@"Error message shown when user tries to update profile with a profile name "
|
||||
@"that is too long.")];
|
||||
return;
|
||||
}
|
||||
|
||||
// Show an activity indicator to block the UI during the profile upload.
|
||||
UIAlertController *alertController = [UIAlertController
|
||||
alertControllerWithTitle:NSLocalizedString(@"PROFILE_VIEW_SAVING",
|
||||
|
@ -379,7 +388,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
|
|||
[self presentViewController:alertController
|
||||
animated:YES
|
||||
completion:^{
|
||||
[OWSProfileManager.sharedManager updateLocalProfileName:[self normalizedProfileName]
|
||||
[OWSProfileManager.sharedManager updateLocalProfileName:normalizedProfileName
|
||||
avatarImage:self.avatar
|
||||
success:^{
|
||||
[alertController dismissViewControllerAnimated:NO
|
||||
|
|
|
@ -1090,6 +1090,9 @@
|
|||
/* Label for action that clear's the user's profile avatar */
|
||||
"PROFILE_VIEW_CLEAR_AVATAR" = "Clear Avatar";
|
||||
|
||||
/* Error message shown when user tries to update profile with a profile name that is too long. */
|
||||
"PROFILE_VIEW_ERROR_PROFILE_NAME_TOO_LONG" = "Your profile name is too long.";
|
||||
|
||||
/* Error message shown when a profile update fails. */
|
||||
"PROFILE_VIEW_ERROR_UPDATE_FAILED" = "Profile update failed.";
|
||||
|
||||
|
@ -1114,9 +1117,6 @@
|
|||
/* Alert title that indicates the user's profile view is being saved. */
|
||||
"PROFILE_VIEW_SAVING" = "Saving...";
|
||||
|
||||
/* Button to skip the profile view in the registration workflow. */
|
||||
"PROFILE_VIEW_SKIP_BUTTON" = "Skip";
|
||||
|
||||
/* Title for the profile view. */
|
||||
"PROFILE_VIEW_TITLE" = "Profile";
|
||||
|
||||
|
|
Loading…
Reference in New Issue