mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Handle split contacts in storage service when in PNP mode.
This commit is contained in:
@@ -2236,6 +2236,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
|
||||
if (update(id, contentValues)) {
|
||||
Log.i(TAG, "[WithSplit] Newly marked $id as unregistered.")
|
||||
markNeedsSync(id)
|
||||
ApplicationDependencies.getDatabaseObserver().notifyRecipientChanged(id)
|
||||
}
|
||||
|
||||
@@ -2254,10 +2255,33 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
|
||||
if (update(id, contentValues)) {
|
||||
Log.i(TAG, "[WithoutSplit] Newly marked $id as unregistered.")
|
||||
markNeedsSync(id)
|
||||
ApplicationDependencies.getDatabaseObserver().notifyRecipientChanged(id)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the target recipient's E164+PNI, then creates a new recipient with that E164+PNI.
|
||||
* Done so we can match a split contact during storage sync.
|
||||
*/
|
||||
fun splitForStorageSync(storageId: ByteArray) {
|
||||
check(FeatureFlags.phoneNumberPrivacy())
|
||||
|
||||
val record = getByStorageId(storageId)!!
|
||||
check(record.serviceId != null && record.pni != null && record.serviceId != record.pni)
|
||||
|
||||
writableDatabase
|
||||
.update(TABLE_NAME)
|
||||
.values(
|
||||
PNI_COLUMN to null,
|
||||
PHONE to null
|
||||
)
|
||||
.where("$ID = ?", record.id)
|
||||
.run()
|
||||
|
||||
getAndPossiblyMerge(record.pni, record.pni, record.e164)
|
||||
}
|
||||
|
||||
fun bulkUpdatedRegisteredStatus(registered: Map<RecipientId, ServiceId?>, unregistered: Collection<RecipientId>) {
|
||||
writableDatabase.withinTransaction {
|
||||
val registeredWithServiceId: Set<RecipientId> = getRegisteredWithServiceIds()
|
||||
|
||||
Reference in New Issue
Block a user