mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Rotate profile key when learning of a block by a linked device.
This commit is contained in:
committed by
Jeffrey Starke
parent
cd26929d39
commit
9ccdbb8e40
@@ -860,7 +860,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
}
|
||||
|
||||
fun applyStorageSyncContactInsert(insert: SignalContactRecord) {
|
||||
fun applyStorageSyncContactInsert(insert: SignalContactRecord, rotateProfileKeyOnBlock: Boolean): Boolean {
|
||||
val db = writableDatabase
|
||||
val threadDatabase = threads
|
||||
val values = getValuesForStorageContact(insert, true)
|
||||
@@ -877,6 +877,12 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
recipientId = RecipientId.from(id)
|
||||
}
|
||||
|
||||
val profileKeyRotated = if (insert.proto.blocked) {
|
||||
RecipientUtil.updateProfileSharingAfterBlock(Recipient.resolved(recipientId), rotateProfileKeyOnBlock)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
if (insert.proto.identityKey.isNotEmpty() && (insert.proto.signalAci != null || insert.proto.signalPni != null)) {
|
||||
try {
|
||||
val serviceId: ServiceId = insert.proto.signalAci ?: insert.proto.signalPni!!
|
||||
@@ -892,9 +898,11 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
|
||||
threadDatabase.applyStorageSyncUpdate(recipientId, insert)
|
||||
|
||||
return profileKeyRotated
|
||||
}
|
||||
|
||||
fun applyStorageSyncContactUpdate(update: StorageRecordUpdate<SignalContactRecord>) {
|
||||
fun applyStorageSyncContactUpdate(update: StorageRecordUpdate<SignalContactRecord>, rotateProfileKeyOnBlock: Boolean): Boolean {
|
||||
val db = writableDatabase
|
||||
val identityStore = AppDependencies.protocolStore.aci().identities()
|
||||
val values = getValuesForStorageContact(update.new, false)
|
||||
@@ -925,6 +933,12 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
db.update(TABLE_NAME, clearValues, ID_WHERE, SqlUtil.buildArgs(recipientId))
|
||||
}
|
||||
|
||||
val profileKeyRotated = if (update.new.proto.blocked && !update.old.proto.blocked) {
|
||||
RecipientUtil.updateProfileSharingAfterBlock(Recipient.resolved(recipientId), rotateProfileKeyOnBlock)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
||||
try {
|
||||
val oldIdentityRecord = identityStore.getIdentityRecord(recipientId)
|
||||
if (update.new.proto.identityKey.isNotEmpty() && update.new.proto.signalAci != null) {
|
||||
@@ -948,6 +962,8 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
|
||||
threads.applyStorageSyncUpdate(recipientId, update.new)
|
||||
AppDependencies.databaseObserver.notifyRecipientChanged(recipientId)
|
||||
|
||||
return profileKeyRotated
|
||||
}
|
||||
|
||||
private fun resolvePotentialUsernameConflicts(username: String?, recipientId: RecipientId) {
|
||||
|
||||
Reference in New Issue
Block a user