Fix change number obsolete profile handling
This commit is contained in:
parent
9e18a245df
commit
037da84de1
@ -153,6 +153,19 @@ extension SignalRecipient {
|
||||
newUuid: newServiceIdString,
|
||||
transaction: transaction.unwrapGrdbWrite)
|
||||
|
||||
if let oldPhoneNumber {
|
||||
// If we have an `oldPhoneNumber`, it means that value is now detached from
|
||||
// everything. If there is any profile that refers exclusively to that
|
||||
// phone number, we can delete it. (If there are profiles that refer to
|
||||
// some other ACI, we should keep those since they're for accounts that are
|
||||
// potentially still valid.)
|
||||
let sql = """
|
||||
DELETE FROM \(UserProfileRecord.databaseTableName)
|
||||
WHERE \(userProfileColumn: .recipientPhoneNumber) = ? AND \(userProfileColumn: .recipientUUID) IS NULL
|
||||
"""
|
||||
transaction.unwrapGrdbWrite.execute(sql: sql, arguments: [oldPhoneNumber])
|
||||
}
|
||||
|
||||
if let newServiceId,
|
||||
let localAci = tsAccountManager.localUuid(with: transaction).map({ ServiceId($0) }),
|
||||
localAci != newServiceId,
|
||||
@ -247,8 +260,6 @@ extension SignalRecipient {
|
||||
}
|
||||
|
||||
if let obsoleteAddress {
|
||||
ProfileFetcherJob.clearProfileState(address: obsoleteAddress, transaction: transaction)
|
||||
|
||||
transaction.addAsyncCompletion(queue: .global()) {
|
||||
Self.udManager.setUnidentifiedAccessMode(.unknown, address: obsoleteAddress)
|
||||
}
|
||||
|
||||
@ -571,33 +571,6 @@ public class ProfileFetcherJob: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
public static func clearProfileState(address: SignalServiceAddress, transaction: SDSAnyWriteTransaction) {
|
||||
|
||||
// TODO: We could immediately discard profile state for this address as well.
|
||||
|
||||
self.profileManager.updateProfile(
|
||||
for: address,
|
||||
givenName: nil,
|
||||
familyName: nil,
|
||||
bio: nil,
|
||||
bioEmoji: nil,
|
||||
avatarUrlPath: nil,
|
||||
optionalAvatarFileUrl: nil,
|
||||
profileBadges: nil,
|
||||
lastFetch: Date.distantPast,
|
||||
isStoriesCapable: false,
|
||||
canReceiveGiftBadges: false,
|
||||
isPniCapable: false,
|
||||
userProfileWriter: .profileFetch,
|
||||
authedAccount: .implicit(),
|
||||
transaction: transaction
|
||||
)
|
||||
|
||||
self.paymentsHelper.setArePaymentsEnabled(for: address,
|
||||
hasPaymentsEnabled: false,
|
||||
transaction: transaction)
|
||||
}
|
||||
|
||||
private static func updateUnidentifiedAccess(address: SignalServiceAddress,
|
||||
verifier: Data?,
|
||||
hasUnrestrictedAccess: Bool) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user