Merge branch 'release/3.20.1' into release/3.21.0
This commit is contained in:
commit
274aa326cb
@ -453,6 +453,13 @@ const NSString *kNSNotificationKey_WasLocallyInitiated = @"kNSNotificationKey_Wa
|
||||
});
|
||||
}
|
||||
|
||||
- (void)reuploadLocalProfile
|
||||
{
|
||||
[self reuploadLocalProfilePromiseObjc].then(^{ OWSLogInfo(@"Done."); }).catch(^(NSError *error) {
|
||||
OWSFailDebug(@"Error: %@", error);
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark - Profile Key Rotation
|
||||
|
||||
- (nullable NSString *)groupKeyForGroupId:(NSData *)groupId {
|
||||
|
||||
@ -130,6 +130,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)didSendOrReceiveMessageFromAddress:(SignalServiceAddress *)address
|
||||
transaction:(SDSAnyWriteTransaction *)transaction;
|
||||
|
||||
- (void)reuploadLocalProfile;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -322,6 +322,11 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
- (void)reuploadLocalProfile
|
||||
{
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@ -34,7 +34,7 @@ private class Atomics {
|
||||
public class AtomicBool: NSObject {
|
||||
private let value = AtomicValue<Bool>(false)
|
||||
|
||||
@objc
|
||||
@objc(initWithValue:)
|
||||
public required init(_ value: Bool) {
|
||||
self.value.set(value)
|
||||
}
|
||||
|
||||
@ -125,6 +125,8 @@ public enum ExperienceUpgradeId: String, CaseIterable {
|
||||
switch self {
|
||||
case .pinReminder:
|
||||
return false
|
||||
case .messageRequests:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
@ -140,6 +142,8 @@ public enum ExperienceUpgradeId: String, CaseIterable {
|
||||
return false
|
||||
case .contactPermissionReminder:
|
||||
return false
|
||||
case .messageRequests:
|
||||
return false
|
||||
default:
|
||||
return true
|
||||
}
|
||||
@ -261,7 +265,10 @@ public class ExperienceUpgradeFinder: NSObject {
|
||||
|
||||
while true {
|
||||
guard let experienceUpgrade = try? cursor.next() else { break }
|
||||
|
||||
guard experienceUpgrade.id.shouldSave else {
|
||||
// Ignore saved upgrades that we don't currently save.
|
||||
continue
|
||||
}
|
||||
if !experienceUpgrade.isComplete && !experienceUpgrade.hasCompletedVisibleDuration {
|
||||
experienceUpgrades.append(experienceUpgrade)
|
||||
}
|
||||
|
||||
@ -351,6 +351,18 @@ NSUInteger const kUserProfileSchemaVersion = 1;
|
||||
|
||||
#pragma mark - Update With... Methods
|
||||
|
||||
+ (BOOL)shouldReuploadProtectedProfileName
|
||||
{
|
||||
// Only re-upload once per launch.
|
||||
//
|
||||
// This value will only be accessed within write transactions,
|
||||
// so it is thread-safe.
|
||||
static BOOL hasReuploaded = NO;
|
||||
BOOL canReupload = !hasReuploaded;
|
||||
hasReuploaded = YES;
|
||||
return canReupload;
|
||||
}
|
||||
|
||||
// Similar in spirit to anyUpdateWithTransaction,
|
||||
// but with significant differences.
|
||||
//
|
||||
@ -409,6 +421,25 @@ NSUInteger const kUserProfileSchemaVersion = 1;
|
||||
equalTo:profile.familyName];
|
||||
BOOL avatarUrlPathDidChange = ![NSObject isNullableObject:avatarUrlPathBefore
|
||||
equalTo:profile.avatarUrlPath];
|
||||
|
||||
if ([profile.address.phoneNumber
|
||||
isEqualToString:kLocalProfileInvariantPhoneNumber]) {
|
||||
BOOL hasValidProfileNameBefore = givenNameBefore.length > 0;
|
||||
BOOL hasValidProfileNameAfter = profile.givenName.length > 0;
|
||||
if (hasValidProfileNameBefore && !hasValidProfileNameAfter) {
|
||||
OWSFailDebug(@"Restoring local profile name.");
|
||||
// Profile names are required; never clear the profile
|
||||
// name for the local user.
|
||||
profile.givenName = givenNameBefore;
|
||||
|
||||
if (OWSUserProfile.shouldReuploadProtectedProfileName) {
|
||||
[transaction addAsyncCompletionOffMain:^{
|
||||
[self.profileManager reuploadLocalProfile];
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *profileKeyDescription;
|
||||
if (profile.profileKey.keyData != nil) {
|
||||
if (SSKDebugFlags.internalLogging) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user