Always perform CDSI lookups when starting new chats.

This commit is contained in:
Greyson Parrelli
2024-03-06 12:11:52 -05:00
committed by Alex Hart
parent 184c1b67cc
commit 2e4ac7ede1
15 changed files with 264 additions and 126 deletions

View File

@@ -433,6 +433,15 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
return readableDatabase.exists(TABLE_NAME).where("$ACI_COLUMN = ? AND $PNI_COLUMN = ?", serviceId.toString(), pni.toString()).run()
}
fun getByE164IfRegisteredAndDiscoverable(e164: String): RecipientId? {
return readableDatabase
.select(ID)
.from(TABLE_NAME)
.where("$E164 = ? AND $REGISTERED = ${RegisteredState.REGISTERED.id} AND $PHONE_NUMBER_DISCOVERABLE = ${PhoneNumberDiscoverableState.DISCOVERABLE.id} AND ($PNI_COLUMN NOT NULL OR $ACI_COLUMN NOT NULL)", e164)
.run()
.readToSingleObject { RecipientId.from(it.requireLong(ID)) }
}
@JvmOverloads
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?, changeSelf: Boolean = false): RecipientId {
require(serviceId != null || e164 != null) { "Must provide an ACI or E164!" }
@@ -2267,6 +2276,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
getAndPossiblyMerge(null, record.pni, record.e164)
}
fun processIndividualCdsLookup(aci: ACI?, pni: PNI, e164: String): RecipientId {
return getAndPossiblyMerge(aci = aci, pni = pni, e164 = e164)
}
/**
* Processes CDSv2 results, merging recipients as necessary. Does not mark users as
* registered.