Add additional log around change number and set PNI.

This commit is contained in:
Cody Henthorne
2022-01-26 15:13:52 -05:00
committed by GitHub
parent 8e5500826c
commit 053b19846b
5 changed files with 45 additions and 8 deletions

View File

@@ -99,6 +99,7 @@ import java.util.LinkedHashSet
import java.util.LinkedList
import java.util.Objects
import java.util.concurrent.TimeUnit
import kotlin.jvm.Throws
import kotlin.math.max
open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) : Database(context, databaseHelper) {
@@ -418,14 +419,14 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
fetch.id
}
is RecipientFetch.MatchAndUpdateE164 -> {
setPhoneNumber(fetch.id, fetch.e164)
setPhoneNumberOrThrowSilent(fetch.id, fetch.e164)
recipientsNeedingRefresh = listOf(fetch.id)
recipientChangedNumber = fetch.changedNumber
fetch.id
}
is RecipientFetch.MatchAndReassignE164 -> {
removePhoneNumber(fetch.e164Id, db)
setPhoneNumber(fetch.id, fetch.e164)
setPhoneNumberOrThrowSilent(fetch.id, fetch.e164)
recipientsNeedingRefresh = listOf(fetch.id, fetch.e164Id)
recipientChangedNumber = fetch.changedNumber
fetch.id
@@ -1749,12 +1750,16 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
putNull(PHONE)
putNull(PNI_COLUMN)
}
db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(recipientId))
if (update(recipientId, values)) {
rotateStorageId(recipientId)
}
}
/**
* Should only use if you are confident that this will not result in any contact merging.
*/
@Throws(SQLiteConstraintException::class)
fun setPhoneNumberOrThrow(id: RecipientId, e164: String) {
val contentValues = ContentValues(1).apply {
put(PHONE, e164)
@@ -1766,6 +1771,16 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
}
}
@Throws(SQLiteConstraintException::class)
fun setPhoneNumberOrThrowSilent(id: RecipientId, e164: String) {
val contentValues = ContentValues(1).apply {
put(PHONE, e164)
}
if (update(id, contentValues)) {
rotateStorageId(id)
}
}
fun updateSelfPhone(e164: String) {
val db = writableDatabase