Remove concept of 'highTrust' that is no longer necessary.

fork-5.53.8
Greyson Parrelli 2022-07-06 15:48:32 -04:00 zatwierdzone przez Alex Hart
rodzic d17896ea09
commit 04cf8676cc
44 zmienionych plików z 222 dodań i 374 usunięć

Wyświetl plik

@ -92,18 +92,8 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
/** If all you have is an ACI, you can just store that, regardless of trust level. */ /** If all you have is an ACI, you can just store that, regardless of trust level. */
@Test @Test
fun getAndPossiblyMerge_aciAndE164MapToNoOne_aciOnly_highTrust() { fun getAndPossiblyMerge_aciAndE164MapToNoOne_aciOnly() {
val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, null, true) val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, null)
val recipient = Recipient.resolved(recipientId)
assertEquals(ACI_A, recipient.requireServiceId())
assertFalse(recipient.hasE164())
}
/** If all you have is an ACI, you can just store that, regardless of trust level. */
@Test
fun getAndPossiblyMerge_aciAndE164MapToNoOne_aciOnly_lowTrust() {
val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, null, false)
val recipient = Recipient.resolved(recipientId) val recipient = Recipient.resolved(recipientId)
assertEquals(ACI_A, recipient.requireServiceId()) assertEquals(ACI_A, recipient.requireServiceId())
@ -112,18 +102,8 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
/** If all you have is an E164, you can just store that, regardless of trust level. */ /** If all you have is an E164, you can just store that, regardless of trust level. */
@Test @Test
fun getAndPossiblyMerge_aciAndE164MapToNoOne_e164Only_highTrust() { fun getAndPossiblyMerge_aciAndE164MapToNoOne_e164Only() {
val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A, true) val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A)
val recipient = Recipient.resolved(recipientId)
assertEquals(E164_A, recipient.requireE164())
assertFalse(recipient.hasServiceId())
}
/** If all you have is an E164, you can just store that, regardless of trust level. */
@Test
fun getAndPossiblyMerge_aciAndE164MapToNoOne_e164Only_lowTrust() {
val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A, false)
val recipient = Recipient.resolved(recipientId) val recipient = Recipient.resolved(recipientId)
assertEquals(E164_A, recipient.requireE164()) assertEquals(E164_A, recipient.requireE164())
@ -132,34 +112,24 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
/** With high trust, you can associate an ACI-e164 pair. */ /** With high trust, you can associate an ACI-e164 pair. */
@Test @Test
fun getAndPossiblyMerge_aciAndE164MapToNoOne_aciAndE164_highTrust() { fun getAndPossiblyMerge_aciAndE164MapToNoOne_aciAndE164() {
val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val recipient = Recipient.resolved(recipientId) val recipient = Recipient.resolved(recipientId)
assertEquals(ACI_A, recipient.requireServiceId()) assertEquals(ACI_A, recipient.requireServiceId())
assertEquals(E164_A, recipient.requireE164()) assertEquals(E164_A, recipient.requireE164())
} }
/** With low trust, you cannot associate an ACI-e164 pair, and therefore can only store the ACI. */
@Test
fun getAndPossiblyMerge_aciAndE164MapToNoOne_aciAndE164_lowTrust() {
val recipientId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, false)
val recipient = Recipient.resolved(recipientId)
assertEquals(ACI_A, recipient.requireServiceId())
assertFalse(recipient.hasE164())
}
// ============================================================== // ==============================================================
// If the ACI maps to an existing user, but the E164 doesn't // If the ACI maps to an existing user, but the E164 doesn't
// ============================================================== // ==============================================================
/** With high trust, you can associate an e164 with an existing ACI. */ /** You can associate an e164 with an existing ACI. */
@Test @Test
fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciAndE164_highTrust() { fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciAndE164() {
val existingId: RecipientId = recipientDatabase.getOrInsertFromServiceId(ACI_A) val existingId: RecipientId = recipientDatabase.getOrInsertFromServiceId(ACI_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingId, retrievedId) assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -167,25 +137,12 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assertEquals(E164_A, retrievedRecipient.requireE164()) assertEquals(E164_A, retrievedRecipient.requireE164())
} }
/** With low trust, you cannot associate an ACI-e164 pair, and therefore cannot store the e164. */ /** Basically the change number case. Update the existing user. */
@Test @Test
fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciAndE164_lowTrust() { fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciAndE164_2() {
val existingId: RecipientId = recipientDatabase.getOrInsertFromServiceId(ACI_A) val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, false) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B)
assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId)
assertEquals(ACI_A, retrievedRecipient.requireServiceId())
assertFalse(retrievedRecipient.hasE164())
}
/** Basically the change number case. High trust lets you update the existing user. */
@Test
fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciAndE164_2_highTrust() {
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, true)
assertEquals(existingId, retrievedId) assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -193,29 +150,16 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assertEquals(E164_B, retrievedRecipient.requireE164()) assertEquals(E164_B, retrievedRecipient.requireE164())
} }
/** Low trust means you cant update the underlying data, but you also dont need to create any new rows. */
@Test
fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciAndE164_2_lowTrust() {
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, false)
assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId)
assertEquals(ACI_A, retrievedRecipient.requireServiceId())
assertEquals(E164_A, retrievedRecipient.requireE164())
}
// ============================================================== // ==============================================================
// If the E164 maps to an existing user, but the ACI doesn't // If the E164 maps to an existing user, but the ACI doesn't
// ============================================================== // ==============================================================
/** With high trust, you can associate an e164 with an existing ACI. */ /** You can associate an e164 with an existing ACI. */
@Test @Test
fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_aciAndE164_highTrust() { fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_aciAndE164() {
val existingId: RecipientId = recipientDatabase.getOrInsertFromE164(E164_A) val existingId: RecipientId = recipientDatabase.getOrInsertFromE164(E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingId, retrievedId) assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -223,30 +167,13 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assertEquals(E164_A, retrievedRecipient.requireE164()) assertEquals(E164_A, retrievedRecipient.requireE164())
} }
/** With low trust, you cannot associate an ACI-e164 pair, and therefore need to create a new person with just the ACI. */ /** We never change the ACI of an existing row. New ACI = new person. Take the e164 from the current holder. */
@Test @Test
fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_aciAndE164_lowTrust() { fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_aciAndE164_2() {
val existingId: RecipientId = recipientDatabase.getOrInsertFromE164(E164_A) val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, false)
assertNotEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId)
assertEquals(ACI_A, retrievedRecipient.requireServiceId())
assertFalse(retrievedRecipient.hasE164())
val existingRecipient = Recipient.resolved(existingId)
assertEquals(E164_A, existingRecipient.requireE164())
assertFalse(existingRecipient.hasServiceId())
}
/** We never change the ACI of an existing row. New ACI = new person, regardless of trust. But high trust lets us take the e164 from the current holder. */
@Test
fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_aciAndE164_2_highTrust() {
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true)
recipientDatabase.setPni(existingId, PNI_A) recipientDatabase.setPni(existingId, PNI_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A)
recipientDatabase.setPni(retrievedId, PNI_A) recipientDatabase.setPni(retrievedId, PNI_A)
assertNotEquals(existingId, retrievedId) assertNotEquals(existingId, retrievedId)
@ -259,35 +186,18 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assertFalse(existingRecipient.hasE164()) assertFalse(existingRecipient.hasE164())
} }
/** We never change the ACI of an existing row. New ACI = new person, regardless of trust. And low trust means we cant take the e164. */ /** We never want to remove the e164 of our own contact entry. Leave the e164 alone. */
@Test @Test
fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_aciAndE164_2_lowTrust() { fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_e164BelongsToLocalUser() {
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A, false)
assertNotEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId)
assertEquals(ACI_B, retrievedRecipient.requireServiceId())
assertFalse(retrievedRecipient.hasE164())
val existingRecipient = Recipient.resolved(existingId)
assertEquals(ACI_A, existingRecipient.requireServiceId())
assertEquals(E164_A, existingRecipient.requireE164())
}
/** We never want to remove the e164 of our own contact entry. So basically treat this as a low-trust case, and leave the e164 alone. */
@Test
fun getAndPossiblyMerge_e164MapsToExistingUserButAciDoesNot_e164BelongsToLocalUser_highTrust() {
val dataSet = KeyValueDataSet().apply { val dataSet = KeyValueDataSet().apply {
putString(AccountValues.KEY_E164, E164_A) putString(AccountValues.KEY_E164, E164_A)
putString(AccountValues.KEY_ACI, ACI_A.toString()) putString(AccountValues.KEY_ACI, ACI_A.toString())
} }
SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet))) SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet)))
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A)
assertNotEquals(existingId, retrievedId) assertNotEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -303,12 +213,12 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
// If both the ACI and E164 map to an existing user // If both the ACI and E164 map to an existing user
// ============================================================== // ==============================================================
/** Regardless of trust, if your ACI and e164 match, youre good. */ /** If your ACI and e164 match, youre good. */
@Test @Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_highTrust() { fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164() {
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingId, retrievedId) assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -316,16 +226,16 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assertEquals(E164_A, retrievedRecipient.requireE164()) assertEquals(E164_A, retrievedRecipient.requireE164())
} }
/** High trust lets you merge two different users into one. You should prefer the ACI user. Not shown: merging threads, dropping e164 sessions, etc. */ /** Merge two different users into one. You should prefer the ACI user. Not shown: merging threads, dropping e164 sessions, etc. */
@Test @Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_merge_highTrust() { fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_merge() {
val changeNumberListener = ChangeNumberListener() val changeNumberListener = ChangeNumberListener()
changeNumberListener.enqueue() changeNumberListener.enqueue()
val existingAciId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, null, true) val existingAciId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, null)
val existingE164Id: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A, true) val existingE164Id: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingAciId, retrievedId) assertEquals(existingAciId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -339,16 +249,16 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assertFalse(changeNumberListener.numberChangeWasEnqueued) assertFalse(changeNumberListener.numberChangeWasEnqueued)
} }
/** Same as [getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_merge_highTrust], but with a number change. */ /** Same as [getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_merge], but with a number change. */
@Test @Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_merge_highTrust_changedNumber() { fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_merge_changedNumber() {
val changeNumberListener = ChangeNumberListener() val changeNumberListener = ChangeNumberListener()
changeNumberListener.enqueue() changeNumberListener.enqueue()
val existingAciId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, true) val existingAciId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B)
val existingE164Id: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A, true) val existingE164Id: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingAciId, retrievedId) assertEquals(existingAciId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -362,34 +272,16 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assert(changeNumberListener.numberChangeWasEnqueued) assert(changeNumberListener.numberChangeWasEnqueued)
} }
/** Low trust means you cant merge. If youre retrieving a user from the table with this data, prefer the ACI one. */ /** No new rules here, just a more complex scenario to show how different rules interact. */
@Test @Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_lowTrust() { fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_complex() {
val existingAciId: RecipientId = recipientDatabase.getOrInsertFromServiceId(ACI_A)
val existingE164Id: RecipientId = recipientDatabase.getOrInsertFromE164(E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, false)
assertEquals(existingAciId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId)
assertEquals(ACI_A, retrievedRecipient.requireServiceId())
assertFalse(retrievedRecipient.hasE164())
val existingE164Recipient = Recipient.resolved(existingE164Id)
assertEquals(E164_A, existingE164Recipient.requireE164())
assertFalse(existingE164Recipient.hasServiceId())
}
/** Another high trust case. No new rules here, just a more complex scenario to show how different rules interact. */
@Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_complex_highTrust() {
val changeNumberListener = ChangeNumberListener() val changeNumberListener = ChangeNumberListener()
changeNumberListener.enqueue() changeNumberListener.enqueue()
val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, true) val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B)
val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A, true) val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingId1, retrievedId) assertEquals(existingId1, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -403,34 +295,16 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assert(changeNumberListener.numberChangeWasEnqueued) assert(changeNumberListener.numberChangeWasEnqueued)
} }
/** Another low trust case. No new rules here, just a more complex scenario to show how different rules interact. */
@Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_complex_lowTrust() {
val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, true)
val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A, true)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, false)
assertEquals(existingId1, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId)
assertEquals(ACI_A, retrievedRecipient.requireServiceId())
assertEquals(E164_B, retrievedRecipient.requireE164())
val existingRecipient2 = Recipient.resolved(existingId2)
assertEquals(ACI_B, existingRecipient2.requireServiceId())
assertEquals(E164_A, existingRecipient2.requireE164())
}
/** /**
* Another high trust case that results in a merge. Nothing strictly new here, but this case is called out because its a merge but *also* an E164 change, * Another case that results in a merge. Nothing strictly new here, but this case is called out because its a merge but *also* an E164 change,
* which clients may need to know for UX purposes. * which clients may need to know for UX purposes.
*/ */
@Test @Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_mergeAndPhoneNumberChange_highTrust() { fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_aciAndE164_mergeAndPhoneNumberChange() {
val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, true) val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B)
val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A, true) val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(null, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingId1, retrievedId) assertEquals(existingId1, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -443,7 +317,7 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
assertEquals(retrievedId, recipientWithId2.id) assertEquals(retrievedId, recipientWithId2.id)
} }
/** We never want to remove the e164 of our own contact entry. So basically treat this as a low-trust case, and leave the e164 alone. */ /** We never want to remove the e164 of our own contact entry. Leave the e164 alone. */
@Test @Test
fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_e164BelongsToLocalUser() { fun getAndPossiblyMerge_bothAciAndE164MapToExistingUser_e164BelongsToLocalUser() {
val dataSet = KeyValueDataSet().apply { val dataSet = KeyValueDataSet().apply {
@ -452,10 +326,10 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
} }
SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet))) SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet)))
val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A, true) val existingId1: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_B, E164_A)
val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, null, true) val existingId2: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, null)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
assertEquals(existingId2, retrievedId) assertEquals(existingId2, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -469,16 +343,16 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
/** This is a case where normally we'd update the E164 of a user, but here the changeSelf flag is disabled, so we shouldn't. */ /** This is a case where normally we'd update the E164 of a user, but here the changeSelf flag is disabled, so we shouldn't. */
@Test @Test
fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciBelongsToLocalUser_highTrust_changeSelfFalse() { fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciBelongsToLocalUser_changeSelfFalse() {
val dataSet = KeyValueDataSet().apply { val dataSet = KeyValueDataSet().apply {
putString(AccountValues.KEY_E164, E164_A) putString(AccountValues.KEY_E164, E164_A)
putString(AccountValues.KEY_ACI, ACI_A.toString()) putString(AccountValues.KEY_ACI, ACI_A.toString())
} }
SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet))) SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet)))
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, highTrust = true, changeSelf = false) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, changeSelf = false)
assertEquals(existingId, retrievedId) assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -488,16 +362,16 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
/** This is a case where we're changing our own number, and it's allowed because changeSelf = true. */ /** This is a case where we're changing our own number, and it's allowed because changeSelf = true. */
@Test @Test
fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciBelongsToLocalUser_highTrust_changeSelfTrue() { fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_aciBelongsToLocalUser_changeSelfTrue() {
val dataSet = KeyValueDataSet().apply { val dataSet = KeyValueDataSet().apply {
putString(AccountValues.KEY_E164, E164_A) putString(AccountValues.KEY_E164, E164_A)
putString(AccountValues.KEY_ACI, ACI_A.toString()) putString(AccountValues.KEY_ACI, ACI_A.toString())
} }
SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet))) SignalStore.inject(KeyValueStore(MockKeyValuePersistentStorage.withDataSet(dataSet)))
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, highTrust = true, changeSelf = true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, changeSelf = true)
assertEquals(existingId, retrievedId) assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)
@ -507,13 +381,13 @@ class RecipientDatabaseTest_getAndPossiblyMerge {
/** Verifying a case where a change number job is expected to be enqueued. */ /** Verifying a case where a change number job is expected to be enqueued. */
@Test @Test
fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_highTrust_changedNumber() { fun getAndPossiblyMerge_aciMapsToExistingUserButE164DoesNot_changedNumber() {
val changeNumberListener = ChangeNumberListener() val changeNumberListener = ChangeNumberListener()
changeNumberListener.enqueue() changeNumberListener.enqueue()
val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A, true) val existingId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_A)
val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B, true) val retrievedId: RecipientId = recipientDatabase.getAndPossiblyMerge(ACI_A, E164_B)
assertEquals(existingId, retrievedId) assertEquals(existingId, retrievedId)
val retrievedRecipient = Recipient.resolved(retrievedId) val retrievedRecipient = Recipient.resolved(retrievedId)

Wyświetl plik

@ -28,6 +28,7 @@ import org.thoughtcrime.securesms.registration.RegistrationUtil
import org.thoughtcrime.securesms.util.Util import org.thoughtcrime.securesms.util.Util
import org.whispersystems.signalservice.api.profiles.SignalServiceProfile import org.whispersystems.signalservice.api.profiles.SignalServiceProfile
import org.whispersystems.signalservice.api.push.ACI import org.whispersystems.signalservice.api.push.ACI
import org.whispersystems.signalservice.api.push.SignalServiceAddress
import org.whispersystems.signalservice.internal.push.VerifyAccountResponse import org.whispersystems.signalservice.internal.push.VerifyAccountResponse
import java.util.UUID import java.util.UUID
@ -89,7 +90,7 @@ class SignalActivityRule : ExternalResource() {
for (i in 0..4) { for (i in 0..4) {
val aci = ACI.from(UUID.randomUUID()) val aci = ACI.from(UUID.randomUUID())
val recipientId = RecipientId.from(aci, "+1555555101$i") val recipientId = RecipientId.from(SignalServiceAddress(aci, "+1555555101$i"))
SignalDatabase.recipients.setProfileName(recipientId, ProfileName.fromParts("Buddy", "#$i")) SignalDatabase.recipients.setProfileName(recipientId, ProfileName.fromParts("Buddy", "#$i"))
SignalDatabase.recipients.setProfileKeyIfAbsent(recipientId, ProfileKeyUtil.createNew()) SignalDatabase.recipients.setProfileKeyIfAbsent(recipientId, ProfileKeyUtil.createNew())
SignalDatabase.recipients.setCapabilities(recipientId, SignalServiceProfile.Capabilities(true, true, true, true, true, true, true)) SignalDatabase.recipients.setCapabilities(recipientId, SignalServiceProfile.Capabilities(true, true, true, true, true, true, true))

Wyświetl plik

@ -50,7 +50,7 @@ class AvatarPickerRepository(context: Context) {
} }
fun getAvatarForGroup(groupId: GroupId): Single<Avatar> = Single.fromCallable { fun getAvatarForGroup(groupId: GroupId): Single<Avatar> = Single.fromCallable {
val recipient = Recipient.externalGroupExact(applicationContext, groupId) val recipient = Recipient.externalGroupExact(groupId)
if (AvatarHelper.hasAvatar(applicationContext, recipient.id)) { if (AvatarHelper.hasAvatar(applicationContext, recipient.id)) {
try { try {
@ -161,7 +161,7 @@ class AvatarPickerRepository(context: Context) {
} }
fun getDefaultAvatarForGroup(groupId: GroupId): Avatar { fun getDefaultAvatarForGroup(groupId: GroupId): Avatar {
val recipient = Recipient.externalGroupExact(applicationContext, groupId) val recipient = Recipient.externalGroupExact(groupId)
return getDefaultAvatarForGroup(recipient.avatarColor) return getDefaultAvatarForGroup(recipient.avatarColor)
} }

Wyświetl plik

@ -62,7 +62,7 @@ class ConversationSettingsRepository(
fun getThreadId(groupId: GroupId, consumer: (Long) -> Unit) { fun getThreadId(groupId: GroupId, consumer: (Long) -> Unit) {
SignalExecutors.BOUNDED.execute { SignalExecutors.BOUNDED.execute {
val recipientId = Recipient.externalGroupExact(context, groupId).id val recipientId = Recipient.externalGroupExact(groupId).id
consumer(SignalDatabase.threads.getThreadIdIfExistsFor(recipientId)) consumer(SignalDatabase.threads.getThreadIdIfExistsFor(recipientId))
} }
} }
@ -156,7 +156,7 @@ class ConversationSettingsRepository(
fun setMuteUntil(groupId: GroupId, until: Long) { fun setMuteUntil(groupId: GroupId, until: Long) {
SignalExecutors.BOUNDED.execute { SignalExecutors.BOUNDED.execute {
val recipientId = Recipient.externalGroupExact(context, groupId).id val recipientId = Recipient.externalGroupExact(groupId).id
SignalDatabase.recipients.setMuted(recipientId, until) SignalDatabase.recipients.setMuted(recipientId, until)
} }
} }
@ -181,14 +181,14 @@ class ConversationSettingsRepository(
fun block(groupId: GroupId) { fun block(groupId: GroupId) {
SignalExecutors.BOUNDED.execute { SignalExecutors.BOUNDED.execute {
val recipient = Recipient.externalGroupExact(context, groupId) val recipient = Recipient.externalGroupExact(groupId)
RecipientUtil.block(context, recipient) RecipientUtil.block(context, recipient)
} }
} }
fun unblock(groupId: GroupId) { fun unblock(groupId: GroupId) {
SignalExecutors.BOUNDED.execute { SignalExecutors.BOUNDED.execute {
val recipient = Recipient.externalGroupExact(context, groupId) val recipient = Recipient.externalGroupExact(groupId)
RecipientUtil.unblock(context, recipient) RecipientUtil.unblock(context, recipient)
} }
} }
@ -204,7 +204,7 @@ class ConversationSettingsRepository(
fun getExternalPossiblyMigratedGroupRecipientId(groupId: GroupId, consumer: (RecipientId) -> Unit) { fun getExternalPossiblyMigratedGroupRecipientId(groupId: GroupId, consumer: (RecipientId) -> Unit) {
SignalExecutors.BOUNDED.execute { SignalExecutors.BOUNDED.execute {
consumer(Recipient.externalPossiblyMigratedGroup(context, groupId).id) consumer(Recipient.externalPossiblyMigratedGroup(groupId).id)
} }
} }
} }

Wyświetl plik

@ -322,7 +322,7 @@ object ContactDiscovery {
} }
handle.setSystemContactInfo( handle.setSystemContactInfo(
Recipient.externalContact(context, realNumber).id, Recipient.externalContact(realNumber).id,
profileName, profileName,
phoneDetails.displayName, phoneDetails.displayName,
phoneDetails.photoUri, phoneDetails.photoUri,

Wyświetl plik

@ -139,7 +139,7 @@ public class ConversationDataSource implements PagedDataSource<MessageId, Conver
stopwatch.split("attachment-models"); stopwatch.split("attachment-models");
for (ServiceId serviceId : referencedIds) { for (ServiceId serviceId : referencedIds) {
Recipient.resolved(RecipientId.from(serviceId, null)); Recipient.resolved(RecipientId.from(serviceId));
} }
stopwatch.split("recipient-resolves"); stopwatch.split("recipient-resolves");

Wyświetl plik

@ -74,7 +74,7 @@ abstract class ConversationListDataSource implements PagedDataSource<Long, Conve
needsResolve.add(record.getRecipient().getId()); needsResolve.add(record.getRecipient().getId());
} else if (SmsDatabase.Types.isGroupUpdate(record.getType())) { } else if (SmsDatabase.Types.isGroupUpdate(record.getType())) {
UpdateDescription description = MessageRecord.getGv2ChangeDescription(ApplicationDependencies.getApplication(), record.getBody(), null); UpdateDescription description = MessageRecord.getGv2ChangeDescription(ApplicationDependencies.getApplication(), record.getBody(), null);
needsResolve.addAll(description.getMentioned().stream().map(sid -> RecipientId.from(sid, null)).collect(Collectors.toList())); needsResolve.addAll(description.getMentioned().stream().map(RecipientId::from).collect(Collectors.toList()));
} }
} }
} }

Wyświetl plik

@ -69,7 +69,7 @@ public class SignalBaseIdentityKeyStore {
public @NonNull SaveResult saveIdentity(SignalProtocolAddress address, IdentityKey identityKey, boolean nonBlockingApproval) { public @NonNull SaveResult saveIdentity(SignalProtocolAddress address, IdentityKey identityKey, boolean nonBlockingApproval) {
synchronized (LOCK) { synchronized (LOCK) {
IdentityStoreRecord identityRecord = cache.get(address.getName()); IdentityStoreRecord identityRecord = cache.get(address.getName());
RecipientId recipientId = RecipientId.fromExternalPush(address.getName()); RecipientId recipientId = RecipientId.fromSidOrE164(address.getName());
if (identityRecord == null) { if (identityRecord == null) {
Log.i(TAG, "Saving new identity for " + address); Log.i(TAG, "Saving new identity for " + address);

Wyświetl plik

@ -231,7 +231,7 @@ public class GroupDatabase extends Database {
databaseHelper.getSignalWritableDatabase().update(TABLE_NAME, values, GROUP_ID + " = ?", SqlUtil.buildArgs(id)); databaseHelper.getSignalWritableDatabase().update(TABLE_NAME, values, GROUP_ID + " = ?", SqlUtil.buildArgs(id));
Recipient.live(Recipient.externalGroupExact(context, id).getId()).refresh(); Recipient.live(Recipient.externalGroupExact(id).getId()).refresh();
} }
Optional<GroupRecord> getGroup(Cursor cursor) { Optional<GroupRecord> getGroup(Cursor cursor) {
@ -915,7 +915,7 @@ public class GroupDatabase extends Database {
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) { if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
Log.w(TAG, "Seen unknown UUID in members list"); Log.w(TAG, "Seen unknown UUID in members list");
} else { } else {
RecipientId id = RecipientId.from(ServiceId.from(uuid), null); RecipientId id = RecipientId.from(ServiceId.from(uuid));
Optional<RecipientId> remapped = RemappedRecords.getInstance().getRecipient(id); Optional<RecipientId> remapped = RemappedRecords.getInstance().getRecipient(id);
if (remapped.isPresent()) { if (remapped.isPresent()) {
@ -1373,7 +1373,7 @@ public class GroupDatabase extends Database {
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) { if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
unknownMembers++; unknownMembers++;
} else if (includeSelf || !selfUuid.equals(uuid)) { } else if (includeSelf || !selfUuid.equals(uuid)) {
recipients.add(RecipientId.from(ServiceId.from(uuid), null)); recipients.add(RecipientId.from(ServiceId.from(uuid)));
} }
} }
if (memberSet.includePending) { if (memberSet.includePending) {
@ -1381,7 +1381,7 @@ public class GroupDatabase extends Database {
if (UuidUtil.UNKNOWN_UUID.equals(uuid)) { if (UuidUtil.UNKNOWN_UUID.equals(uuid)) {
unknownPending++; unknownPending++;
} else if (includeSelf || !selfUuid.equals(uuid)) { } else if (includeSelf || !selfUuid.equals(uuid)) {
recipients.add(RecipientId.from(ServiceId.from(uuid), null)); recipients.add(RecipientId.from(ServiceId.from(uuid)));
} }
} }
} }

Wyświetl plik

@ -250,7 +250,7 @@ public class IdentityDatabase extends Database {
boolean firstUse = CursorUtil.requireBoolean(cursor, FIRST_USE); boolean firstUse = CursorUtil.requireBoolean(cursor, FIRST_USE);
IdentityKey identity = new IdentityKey(Base64.decode(serializedIdentity), 0); IdentityKey identity = new IdentityKey(Base64.decode(serializedIdentity), 0);
return new IdentityRecord(RecipientId.fromExternalPush(addressName), identity, VerifiedStatus.forState(verifiedStatus), firstUse, timestamp, nonblockingApproval); return new IdentityRecord(RecipientId.fromSidOrE164(addressName), identity, VerifiedStatus.forState(verifiedStatus), firstUse, timestamp, nonblockingApproval);
} }
private void saveIdentityInternal(@NonNull String addressName, private void saveIdentityInternal(@NonNull String addressName,

Wyświetl plik

@ -121,7 +121,7 @@ public final class MentionUtil {
return Stream.of(BodyRangeList.parseFrom(data).getRangesList()) return Stream.of(BodyRangeList.parseFrom(data).getRangesList())
.filter(bodyRange -> bodyRange.getAssociatedValueCase() == BodyRangeList.BodyRange.AssociatedValueCase.MENTIONUUID) .filter(bodyRange -> bodyRange.getAssociatedValueCase() == BodyRangeList.BodyRange.AssociatedValueCase.MENTIONUUID)
.map(mention -> { .map(mention -> {
RecipientId id = Recipient.externalPush(ServiceId.parseOrThrow(mention.getMentionUuid()), null, false).getId(); RecipientId id = Recipient.externalPush(ServiceId.parseOrThrow(mention.getMentionUuid())).getId();
return new Mention(id, mention.getStart(), mention.getLength()); return new Mention(id, mention.getStart(), mention.getLength());
}) })
.toList(); .toList();

Wyświetl plik

@ -2162,7 +2162,7 @@ public class MmsDatabase extends MessageDatabase {
MessageGroupContext.GroupV2Properties groupV2Properties = outgoingGroupUpdateMessage.requireGroupV2Properties(); MessageGroupContext.GroupV2Properties groupV2Properties = outgoingGroupUpdateMessage.requireGroupV2Properties();
members.addAll(Stream.of(groupV2Properties.getAllActivePendingAndRemovedMembers()) members.addAll(Stream.of(groupV2Properties.getAllActivePendingAndRemovedMembers())
.distinct() .distinct()
.map(uuid -> RecipientId.from(ServiceId.from(uuid), null)) .map(uuid -> RecipientId.from(ServiceId.from(uuid)))
.toList()); .toList());
members.remove(Recipient.self().getId()); members.remove(Recipient.self().getId());
} else { } else {

Wyświetl plik

@ -419,11 +419,12 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
return getByColumn(USERNAME, username) return getByColumn(USERNAME, username)
} }
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?, highTrust: Boolean): RecipientId { fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?): RecipientId {
return getAndPossiblyMerge(serviceId, e164, highTrust, false) return getAndPossiblyMerge(serviceId, e164, changeSelf = false)
} }
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?, highTrust: Boolean, changeSelf: Boolean): RecipientId { @VisibleForTesting
fun getAndPossiblyMerge(serviceId: ServiceId?, e164: String?, changeSelf: Boolean): RecipientId {
require(!(serviceId == null && e164 == null)) { "Must provide an ACI or E164!" } require(!(serviceId == null && e164 == null)) { "Must provide an ACI or E164!" }
val db = writableDatabase val db = writableDatabase
@ -435,7 +436,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
db.beginTransaction() db.beginTransaction()
try { try {
val fetch: RecipientFetch = fetchRecipient(serviceId, e164, highTrust, changeSelf) val fetch: RecipientFetch = fetchRecipient(serviceId, e164, changeSelf = changeSelf)
if (fetch.logBundle != null) { if (fetch.logBundle != null) {
Log.w(TAG, fetch.toString()) Log.w(TAG, fetch.toString())
@ -537,7 +538,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
return serviceIdToProfileKey return serviceIdToProfileKey
} }
private fun fetchRecipient(serviceId: ServiceId?, e164: String?, highTrust: Boolean, changeSelf: Boolean): RecipientFetch { private fun fetchRecipient(serviceId: ServiceId?, e164: String?, changeSelf: Boolean): RecipientFetch {
val byE164 = e164?.let { getByE164(it) } ?: Optional.empty() val byE164 = e164?.let { getByE164(it) } ?: Optional.empty()
val byAci = serviceId?.let { getByServiceId(it) } ?: Optional.empty() val byAci = serviceId?.let { getByServiceId(it) } ?: Optional.empty()
@ -548,20 +549,20 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
) )
if (byAci.isPresent && byE164.isPresent && byAci.get() == byE164.get()) { if (byAci.isPresent && byE164.isPresent && byAci.get() == byE164.get()) {
return RecipientFetch.Match(byAci.get(), null) return RecipientFetch.Match(byAci.get(), logs.label("L0"))
} }
if (byAci.isPresent && byE164.isAbsent()) { if (byAci.isPresent && byE164.isAbsent()) {
val aciRecord: RecipientRecord = getRecord(byAci.get()) val aciRecord: RecipientRecord = getRecord(byAci.get())
logs = logs.copy(bySid = aciRecord.toLogDetails()) logs = logs.copy(bySid = aciRecord.toLogDetails())
if (highTrust && e164 != null && (changeSelf || serviceId != SignalStore.account().aci)) { if (e164 != null && (changeSelf || serviceId != SignalStore.account().aci)) {
val changedNumber: RecipientId? = if (aciRecord.e164 != null && aciRecord.e164 != e164) aciRecord.id else null val changedNumber: RecipientId? = if (aciRecord.e164 != null && aciRecord.e164 != e164) aciRecord.id else null
return RecipientFetch.MatchAndUpdateE164(byAci.get(), e164, changedNumber, logs.label("L1")) return RecipientFetch.MatchAndUpdateE164(byAci.get(), e164, changedNumber, logs.label("L1"))
} else if (e164 == null) { } else if (e164 == null) {
return RecipientFetch.Match(byAci.get(), null)
} else {
return RecipientFetch.Match(byAci.get(), logs.label("L2")) return RecipientFetch.Match(byAci.get(), logs.label("L2"))
} else {
return RecipientFetch.Match(byAci.get(), logs.label("L3"))
} }
} }
@ -569,25 +570,19 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
val e164Record: RecipientRecord = getRecord(byE164.get()) val e164Record: RecipientRecord = getRecord(byE164.get())
logs = logs.copy(byE164 = e164Record.toLogDetails()) logs = logs.copy(byE164 = e164Record.toLogDetails())
if (highTrust && serviceId != null && e164Record.serviceId == null) { if (serviceId != null && e164Record.serviceId == null) {
return RecipientFetch.MatchAndUpdateAci(byE164.get(), serviceId, logs.label("L3")) return RecipientFetch.MatchAndUpdateAci(byE164.get(), serviceId, logs.label("L4"))
} else if (highTrust && serviceId != null && e164Record.serviceId != SignalStore.account().aci) { } else if (serviceId != null && e164Record.serviceId != SignalStore.account().aci) {
return RecipientFetch.InsertAndReassignE164(serviceId, e164, byE164.get(), logs.label("L4")) return RecipientFetch.InsertAndReassignE164(serviceId, e164, byE164.get(), logs.label("L5"))
} else if (serviceId != null) { } else if (serviceId != null) {
return RecipientFetch.Insert(serviceId, null, logs.label("L5")) return RecipientFetch.Insert(serviceId, null, logs.label("L6"))
} else { } else {
return RecipientFetch.Match(byE164.get(), null) return RecipientFetch.Match(byE164.get(), logs.label("L7"))
} }
} }
if (byAci.isAbsent() && byE164.isAbsent()) { if (byAci.isAbsent() && byE164.isAbsent()) {
if (highTrust) { return RecipientFetch.Insert(serviceId, e164, logs.label("L8"))
return RecipientFetch.Insert(serviceId, e164, logs.label("L6"))
} else if (serviceId != null) {
return RecipientFetch.Insert(serviceId, null, logs.label("L7"))
} else {
return RecipientFetch.Insert(null, e164, logs.label("L8"))
}
} }
require(byAci.isPresent && byE164.isPresent && byAci.get() != byE164.get()) { "Assumed conditions at this point." } require(byAci.isPresent && byE164.isPresent && byAci.get() != byE164.get()) { "Assumed conditions at this point." }
@ -598,18 +593,14 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
logs = logs.copy(bySid = aciRecord.toLogDetails(), byE164 = e164Record.toLogDetails()) logs = logs.copy(bySid = aciRecord.toLogDetails(), byE164 = e164Record.toLogDetails())
if (e164Record.serviceId == null) { if (e164Record.serviceId == null) {
if (highTrust) { val changedNumber: RecipientId? = if (aciRecord.e164 != null) aciRecord.id else null
val changedNumber: RecipientId? = if (aciRecord.e164 != null) aciRecord.id else null return RecipientFetch.MatchAndMerge(sidId = byAci.get(), e164Id = byE164.get(), changedNumber = changedNumber, logs.label("L9"))
return RecipientFetch.MatchAndMerge(sidId = byAci.get(), e164Id = byE164.get(), changedNumber = changedNumber, logs.label("L9"))
} else {
return RecipientFetch.Match(byAci.get(), logs.label("L10"))
}
} else { } else {
if (highTrust && e164Record.serviceId != SignalStore.account().aci) { if (e164Record.serviceId != SignalStore.account().aci) {
val changedNumber: RecipientId? = if (aciRecord.e164 != null) aciRecord.id else null val changedNumber: RecipientId? = if (aciRecord.e164 != null) aciRecord.id else null
return RecipientFetch.MatchAndReassignE164(id = byAci.get(), e164Id = byE164.get(), e164 = e164!!, changedNumber = changedNumber, logs.label("L11")) return RecipientFetch.MatchAndReassignE164(id = byAci.get(), e164Id = byE164.get(), e164 = e164!!, changedNumber = changedNumber, logs.label("L10"))
} else { } else {
return RecipientFetch.Match(byAci.get(), logs.label("L12")) return RecipientFetch.Match(byAci.get(), logs.label("L11"))
} }
} }
} }
@ -868,7 +859,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
val recipientId: RecipientId val recipientId: RecipientId
if (id < 0) { if (id < 0) {
Log.w(TAG, "[applyStorageSyncContactInsert] Failed to insert. Possibly merging.") Log.w(TAG, "[applyStorageSyncContactInsert] Failed to insert. Possibly merging.")
recipientId = getAndPossiblyMerge(if (insert.address.hasValidServiceId()) insert.address.serviceId else null, insert.address.number.orElse(null), true) recipientId = getAndPossiblyMerge(if (insert.address.hasValidServiceId()) insert.address.serviceId else null, insert.address.number.orElse(null))
db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(recipientId)) db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(recipientId))
} else { } else {
recipientId = RecipientId.from(id) recipientId = RecipientId.from(id)
@ -905,7 +896,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
var recipientId = getByColumn(STORAGE_SERVICE_ID, Base64.encodeBytes(update.old.id.raw)).get() var recipientId = getByColumn(STORAGE_SERVICE_ID, Base64.encodeBytes(update.old.id.raw)).get()
Log.w(TAG, "[applyStorageSyncContactUpdate] Found user $recipientId. Possibly merging.") Log.w(TAG, "[applyStorageSyncContactUpdate] Found user $recipientId. Possibly merging.")
recipientId = getAndPossiblyMerge(if (update.new.address.hasValidServiceId()) update.new.address.serviceId else null, update.new.address.number.orElse(null), true) recipientId = getAndPossiblyMerge(if (update.new.address.hasValidServiceId()) update.new.address.serviceId else null, update.new.address.number.orElse(null))
Log.w(TAG, "[applyStorageSyncContactUpdate] Merged into $recipientId") Log.w(TAG, "[applyStorageSyncContactUpdate] Merged into $recipientId")
db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(recipientId)) db.update(TABLE_NAME, values, ID_WHERE, SqlUtil.buildArgs(recipientId))
@ -960,7 +951,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
throw AssertionError("Had an update, but it didn't match any rows!") throw AssertionError("Had an update, but it didn't match any rows!")
} }
val recipient = Recipient.externalGroupExact(context, GroupId.v1orThrow(update.old.groupId)) val recipient = Recipient.externalGroupExact(GroupId.v1orThrow(update.old.groupId))
threads.applyStorageSyncUpdate(recipient.id, update.new) threads.applyStorageSyncUpdate(recipient.id, update.new)
recipient.live().refresh() recipient.live().refresh()
} }
@ -971,7 +962,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
val values = getValuesForStorageGroupV2(insert, true) val values = getValuesForStorageGroupV2(insert, true)
writableDatabase.insertOrThrow(TABLE_NAME, null, values) writableDatabase.insertOrThrow(TABLE_NAME, null, values)
val recipient = Recipient.externalGroupExact(context, groupId) val recipient = Recipient.externalGroupExact(groupId)
Log.i(TAG, "Creating restore placeholder for $groupId") Log.i(TAG, "Creating restore placeholder for $groupId")
groups.create( groups.create(
@ -1001,7 +992,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
} }
val masterKey = update.old.masterKeyOrThrow val masterKey = update.old.masterKeyOrThrow
val recipient = Recipient.externalGroupExact(context, GroupId.v2(masterKey)) val recipient = Recipient.externalGroupExact(GroupId.v2(masterKey))
updateExtras(recipient.id) { updateExtras(recipient.id) {
it.setHideStory(update.new.shouldHideStory()) it.setHideStory(update.new.shouldHideStory())
@ -1149,7 +1140,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
} }
for (id in groups.allGroupV2Ids) { for (id in groups.allGroupV2Ids) {
val recipient = Recipient.externalGroupExact(context, id!!) val recipient = Recipient.externalGroupExact(id!!)
val recipientId = recipient.id val recipientId = recipient.id
val existing: RecipientRecord = getRecordForSync(recipientId) ?: throw AssertionError() val existing: RecipientRecord = getRecordForSync(recipientId) ?: throw AssertionError()
val key = existing.storageId ?: throw AssertionError() val key = existing.storageId ?: throw AssertionError()
@ -1909,7 +1900,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
Log.w(TAG, "[setPhoneNumber] Hit a conflict when trying to update $id. Possibly merging.") Log.w(TAG, "[setPhoneNumber] Hit a conflict when trying to update $id. Possibly merging.")
val existing: RecipientRecord = getRecord(id) val existing: RecipientRecord = getRecord(id)
val newId = getAndPossiblyMerge(existing.serviceId, e164, true) val newId = getAndPossiblyMerge(existing.serviceId, e164)
Log.w(TAG, "[setPhoneNumber] Resulting id: $newId") Log.w(TAG, "[setPhoneNumber] Resulting id: $newId")
db.setTransactionSuccessful() db.setTransactionSuccessful()
@ -1961,7 +1952,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
db.beginTransaction() db.beginTransaction()
try { try {
val id = Recipient.self().id val id = Recipient.self().id
val newId = getAndPossiblyMerge(SignalStore.account().requireAci(), e164, highTrust = true, changeSelf = true) val newId = getAndPossiblyMerge(SignalStore.account().requireAci(), e164, changeSelf = true)
if (id == newId) { if (id == newId) {
Log.i(TAG, "[updateSelfPhone] Phone updated for self") Log.i(TAG, "[updateSelfPhone] Phone updated for self")
@ -2044,7 +2035,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
Log.w(TAG, "[markRegistered] Hit a conflict when trying to update $id. Possibly merging.") Log.w(TAG, "[markRegistered] Hit a conflict when trying to update $id. Possibly merging.")
val existing = getRecord(id) val existing = getRecord(id)
val newId = getAndPossiblyMerge(serviceId, existing.e164, true) val newId = getAndPossiblyMerge(serviceId, existing.e164)
Log.w(TAG, "[markRegistered] Merged into $newId") Log.w(TAG, "[markRegistered] Merged into $newId")
db.setTransactionSuccessful() db.setTransactionSuccessful()
@ -2099,7 +2090,7 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
} catch (e: SQLiteConstraintException) { } catch (e: SQLiteConstraintException) {
Log.w(TAG, "[bulkUpdateRegisteredStatus] Hit a conflict when trying to update $recipientId. Possibly merging.") Log.w(TAG, "[bulkUpdateRegisteredStatus] Hit a conflict when trying to update $recipientId. Possibly merging.")
val e164 = getRecord(recipientId).e164 val e164 = getRecord(recipientId).e164
val newId = getAndPossiblyMerge(aci, e164, true) val newId = getAndPossiblyMerge(aci, e164)
Log.w(TAG, "[bulkUpdateRegisteredStatus] Merged into $newId") Log.w(TAG, "[bulkUpdateRegisteredStatus] Merged into $newId")
} }
} }

Wyświetl plik

@ -1254,14 +1254,14 @@ public class ThreadDatabase extends Database {
pinnedRecipient = Recipient.externalPush(pinned.getContact().get()); pinnedRecipient = Recipient.externalPush(pinned.getContact().get());
} else if (pinned.getGroupV1Id().isPresent()) { } else if (pinned.getGroupV1Id().isPresent()) {
try { try {
pinnedRecipient = Recipient.externalGroupExact(context, GroupId.v1(pinned.getGroupV1Id().get())); pinnedRecipient = Recipient.externalGroupExact(GroupId.v1(pinned.getGroupV1Id().get()));
} catch (BadGroupIdException e) { } catch (BadGroupIdException e) {
Log.w(TAG, "Failed to parse pinned groupV1 ID!", e); Log.w(TAG, "Failed to parse pinned groupV1 ID!", e);
pinnedRecipient = null; pinnedRecipient = null;
} }
} else if (pinned.getGroupV2MasterKey().isPresent()) { } else if (pinned.getGroupV2MasterKey().isPresent()) {
try { try {
pinnedRecipient = Recipient.externalGroupExact(context, GroupId.v2(new GroupMasterKey(pinned.getGroupV2MasterKey().get()))); pinnedRecipient = Recipient.externalGroupExact(GroupId.v2(new GroupMasterKey(pinned.getGroupV2MasterKey().get())));
} catch (InvalidInputException e) { } catch (InvalidInputException e) {
Log.w(TAG, "Failed to parse pinned groupV2 master key!", e); Log.w(TAG, "Failed to parse pinned groupV2 master key!", e);
pinnedRecipient = null; pinnedRecipient = null;
@ -1524,7 +1524,7 @@ public class ThreadDatabase extends Database {
if (threadRecipient.isPushV2Group()) { if (threadRecipient.isPushV2Group()) {
MessageRecord.InviteAddState inviteAddState = record.getGv2AddInviteState(); MessageRecord.InviteAddState inviteAddState = record.getGv2AddInviteState();
if (inviteAddState != null) { if (inviteAddState != null) {
RecipientId from = RecipientId.from(ServiceId.from(inviteAddState.getAddedOrInvitedBy()), null); RecipientId from = RecipientId.from(ServiceId.from(inviteAddState.getAddedOrInvitedBy()));
if (inviteAddState.isInvited()) { if (inviteAddState.isInvited()) {
Log.i(TAG, "GV2 invite message request from " + from); Log.i(TAG, "GV2 invite message request from " + from);
return Extra.forGroupV2invite(from, individualRecipientId); return Extra.forGroupV2invite(from, individualRecipientId);

Wyświetl plik

@ -99,7 +99,7 @@ public class GroupCallUpdateMessageFactory implements UpdateDescription.Spannabl
return context.getString(R.string.MessageRecord_unknown); return context.getString(R.string.MessageRecord_unknown);
} }
Recipient recipient = Recipient.resolved(RecipientId.from(serviceId, null)); Recipient recipient = Recipient.resolved(RecipientId.from(serviceId));
if (recipient.isSelf()) { if (recipient.isSelf()) {
return context.getString(R.string.MessageRecord_you); return context.getString(R.string.MessageRecord_you);

Wyświetl plik

@ -779,7 +779,7 @@ final class GroupsV2UpdateMessageProducer {
@DrawableRes int iconResource) @DrawableRes int iconResource)
{ {
ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes); ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
RecipientId recipientId = RecipientId.from(serviceId, null); RecipientId recipientId = RecipientId.from(serviceId);
return UpdateDescription.mentioning( return UpdateDescription.mentioning(
Collections.singletonList(serviceId), Collections.singletonList(serviceId),
@ -800,8 +800,8 @@ final class GroupsV2UpdateMessageProducer {
ServiceId sid1 = ServiceId.fromByteStringOrUnknown(uuid1Bytes); ServiceId sid1 = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
ServiceId sid2 = ServiceId.fromByteStringOrUnknown(uuid2Bytes); ServiceId sid2 = ServiceId.fromByteStringOrUnknown(uuid2Bytes);
RecipientId recipientId1 = RecipientId.from(sid1, null); RecipientId recipientId1 = RecipientId.from(sid1);
RecipientId recipientId2 = RecipientId.from(sid2, null); RecipientId recipientId2 = RecipientId.from(sid2);
return UpdateDescription.mentioning( return UpdateDescription.mentioning(
Arrays.asList(sid1, sid2), Arrays.asList(sid1, sid2),
@ -821,7 +821,7 @@ final class GroupsV2UpdateMessageProducer {
@DrawableRes int iconResource) @DrawableRes int iconResource)
{ {
ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes); ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
RecipientId recipientId = RecipientId.from(serviceId, null); RecipientId recipientId = RecipientId.from(serviceId);
return UpdateDescription.mentioning( return UpdateDescription.mentioning(
Collections.singletonList(serviceId), Collections.singletonList(serviceId),
@ -842,7 +842,7 @@ final class GroupsV2UpdateMessageProducer {
@DrawableRes int iconResource) @DrawableRes int iconResource)
{ {
ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes); ServiceId serviceId = ServiceId.fromByteStringOrUnknown(uuid1Bytes);
RecipientId recipientId = RecipientId.from(serviceId, null); RecipientId recipientId = RecipientId.from(serviceId);
return UpdateDescription.mentioning( return UpdateDescription.mentioning(
Collections.singletonList(serviceId), Collections.singletonList(serviceId),

Wyświetl plik

@ -46,7 +46,7 @@ public final class LiveUpdateMessage {
} }
List<LiveData<Recipient>> allMentionedRecipients = Stream.of(updateDescription.getMentioned()) List<LiveData<Recipient>> allMentionedRecipients = Stream.of(updateDescription.getMentioned())
.map(uuid -> Recipient.resolved(RecipientId.from(uuid, null)).live().getLiveData()) .map(uuid -> Recipient.resolved(RecipientId.from(uuid)).live().getLiveData())
.toList(); .toList();
LiveData<?> mentionedRecipientChangeStream = allMentionedRecipients.isEmpty() ? LiveDataUtil.just(new Object()) LiveData<?> mentionedRecipientChangeStream = allMentionedRecipients.isEmpty() ? LiveDataUtil.just(new Object())

Wyświetl plik

@ -196,7 +196,7 @@ final class GroupManagerV1 {
static void updateGroupTimer(@NonNull Context context, @NonNull GroupId.V1 groupId, int expirationTime) { static void updateGroupTimer(@NonNull Context context, @NonNull GroupId.V1 groupId, int expirationTime) {
RecipientDatabase recipientDatabase = SignalDatabase.recipients(); RecipientDatabase recipientDatabase = SignalDatabase.recipients();
ThreadDatabase threadDatabase = SignalDatabase.threads(); ThreadDatabase threadDatabase = SignalDatabase.threads();
Recipient recipient = Recipient.externalGroupExact(context, groupId); Recipient recipient = Recipient.externalGroupExact(groupId);
long threadId = threadDatabase.getOrCreateThreadIdFor(recipient); long threadId = threadDatabase.getOrCreateThreadIdFor(recipient);
recipientDatabase.setExpireMessages(recipient.getId(), expirationTime); recipientDatabase.setExpireMessages(recipient.getId(), expirationTime);

Wyświetl plik

@ -400,7 +400,7 @@ final class GroupManagerV2 {
GroupManager.GroupActionResult groupActionResult = commitChangeWithConflictResolution(selfAci, change); GroupManager.GroupActionResult groupActionResult = commitChangeWithConflictResolution(selfAci, change);
if (avatarChanged) { if (avatarChanged) {
AvatarHelper.setAvatar(context, Recipient.externalGroupExact(context, groupId).getId(), avatarBytes != null ? new ByteArrayInputStream(avatarBytes) : null); AvatarHelper.setAvatar(context, Recipient.externalGroupExact(groupId).getId(), avatarBytes != null ? new ByteArrayInputStream(avatarBytes) : null);
groupDatabase.onAvatarUpdated(groupId, avatarBytes != null); groupDatabase.onAvatarUpdated(groupId, avatarBytes != null);
} }
@ -643,7 +643,7 @@ final class GroupManagerV2 {
if (GroupChangeUtil.changeIsEmpty(change.build())) { if (GroupChangeUtil.changeIsEmpty(change.build())) {
Log.i(TAG, "Change is empty after conflict resolution"); Log.i(TAG, "Change is empty after conflict resolution");
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId); Recipient groupRecipient = Recipient.externalGroupExact(groupId);
long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient); long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient);
return new GroupManager.GroupActionResult(groupRecipient, threadId, 0, Collections.emptyList()); return new GroupManager.GroupActionResult(groupRecipient, threadId, 0, Collections.emptyList());
@ -696,7 +696,7 @@ final class GroupManagerV2 {
final DecryptedGroup decryptedGroupState; final DecryptedGroup decryptedGroupState;
final DecryptedGroup previousGroupState; final DecryptedGroup previousGroupState;
if (!allowWhenBlocked && Recipient.externalGroupExact(context, groupId).isBlocked()) { if (!allowWhenBlocked && Recipient.externalGroupExact(groupId).isBlocked()) {
throw new GroupChangeFailedException("Group is blocked."); throw new GroupChangeFailedException("Group is blocked.");
} }
@ -1232,7 +1232,7 @@ final class GroupManagerV2 {
boolean sendToMembers) boolean sendToMembers)
{ {
GroupId.V2 groupId = GroupId.v2(masterKey); GroupId.V2 groupId = GroupId.v2(masterKey);
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId); Recipient groupRecipient = Recipient.externalGroupExact(groupId);
DecryptedGroupV2Context decryptedGroupV2Context = GroupProtoUtil.createDecryptedGroupV2Context(masterKey, groupMutation, signedGroupChange); DecryptedGroupV2Context decryptedGroupV2Context = GroupProtoUtil.createDecryptedGroupV2Context(masterKey, groupMutation, signedGroupChange);
OutgoingGroupUpdateMessage outgoingMessage = new OutgoingGroupUpdateMessage(groupRecipient, OutgoingGroupUpdateMessage outgoingMessage = new OutgoingGroupUpdateMessage(groupRecipient,
decryptedGroupV2Context, decryptedGroupV2Context,
@ -1276,7 +1276,7 @@ final class GroupManagerV2 {
private static @NonNull List<RecipientId> getPendingMemberRecipientIds(@NonNull List<DecryptedPendingMember> newPendingMembersList) { private static @NonNull List<RecipientId> getPendingMemberRecipientIds(@NonNull List<DecryptedPendingMember> newPendingMembersList) {
return Stream.of(DecryptedGroupUtil.pendingToUuidList(newPendingMembersList)) return Stream.of(DecryptedGroupUtil.pendingToUuidList(newPendingMembersList))
.map(uuid -> RecipientId.from(ServiceId.from(uuid), null)) .map(uuid -> RecipientId.from(ServiceId.from(uuid)))
.toList(); .toList();
} }

Wyświetl plik

@ -91,7 +91,7 @@ public final class GroupProtoUtil {
return Recipient.UNKNOWN; return Recipient.UNKNOWN;
} }
return Recipient.externalPush(serviceId, null, false); return Recipient.externalPush(serviceId);
} }
@WorkerThread @WorkerThread
@ -102,7 +102,7 @@ public final class GroupProtoUtil {
return RecipientId.UNKNOWN; return RecipientId.UNKNOWN;
} }
return RecipientId.from(serviceId, null); return RecipientId.from(serviceId);
} }
public static boolean isMember(@NonNull UUID uuid, @NonNull List<DecryptedMember> membersList) { public static boolean isMember(@NonNull UUID uuid, @NonNull List<DecryptedMember> membersList) {

Wyświetl plik

@ -107,11 +107,11 @@ public final class GroupV1MessageProcessor {
database.create(id, group.getName().orElse(null), members, database.create(id, group.getName().orElse(null), members,
avatar != null && avatar.isPointer() ? avatar.asPointer() : null, null); avatar != null && avatar.isPointer() ? avatar.asPointer() : null, null);
Recipient sender = Recipient.externalHighTrustPush(context, content.getSender()); Recipient sender = Recipient.externalPush(content.getSender());
if (sender.isSystemContact() || sender.isProfileSharing()) { if (sender.isSystemContact() || sender.isProfileSharing()) {
Log.i(TAG, "Auto-enabling profile sharing because 'adder' is trusted. contact: " + sender.isSystemContact() + ", profileSharing: " + sender.isProfileSharing()); Log.i(TAG, "Auto-enabling profile sharing because 'adder' is trusted. contact: " + sender.isSystemContact() + ", profileSharing: " + sender.isProfileSharing());
SignalDatabase.recipients().setProfileSharing(Recipient.externalGroupExact(context, id).getId(), true); SignalDatabase.recipients().setProfileSharing(Recipient.externalGroupExact(id).getId(), true);
} }
return storeMessage(context, content, group, builder.build(), outgoing); return storeMessage(context, content, group, builder.build(), outgoing);
@ -188,7 +188,7 @@ public final class GroupV1MessageProcessor {
@NonNull SignalServiceContent content, @NonNull SignalServiceContent content,
@NonNull GroupRecord record) @NonNull GroupRecord record)
{ {
Recipient sender = Recipient.externalHighTrustPush(context, content.getSender()); Recipient sender = Recipient.externalPush(content.getSender());
if (record.getMembers().contains(sender.getId())) { if (record.getMembers().contains(sender.getId())) {
ApplicationDependencies.getJobManager().add(new PushGroupUpdateJob(sender.getId(), record.getId())); ApplicationDependencies.getJobManager().add(new PushGroupUpdateJob(sender.getId(), record.getId()));
@ -210,7 +210,7 @@ public final class GroupV1MessageProcessor {
GroupContext.Builder builder = createGroupContext(group); GroupContext.Builder builder = createGroupContext(group);
builder.setType(GroupContext.Type.QUIT); builder.setType(GroupContext.Type.QUIT);
RecipientId senderId = RecipientId.fromHighTrust(content.getSender()); RecipientId senderId = RecipientId.from(content.getSender());
if (members.contains(senderId)) { if (members.contains(senderId)) {
database.remove(id, senderId); database.remove(id, senderId);
@ -249,7 +249,7 @@ public final class GroupV1MessageProcessor {
} else { } else {
MessageDatabase smsDatabase = SignalDatabase.sms(); MessageDatabase smsDatabase = SignalDatabase.sms();
String body = Base64.encodeBytes(storage.toByteArray()); String body = Base64.encodeBytes(storage.toByteArray());
IncomingTextMessage incoming = new IncomingTextMessage(Recipient.externalHighTrustPush(context, content.getSender()).getId(), content.getSenderDevice(), content.getTimestamp(), content.getServerReceivedTimestamp(), System.currentTimeMillis(), body, Optional.of(GroupId.v1orThrow(group.getGroupId())), 0, content.isNeedsReceipt(), content.getServerUuid()); IncomingTextMessage incoming = new IncomingTextMessage(Recipient.externalPush(content.getSender()).getId(), content.getSenderDevice(), content.getTimestamp(), content.getServerReceivedTimestamp(), System.currentTimeMillis(), body, Optional.of(GroupId.v1orThrow(group.getGroupId())), 0, content.isNeedsReceipt(), content.getServerUuid());
IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, storage, body); IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, storage, body);
Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage); Optional<InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage);

Wyświetl plik

@ -151,7 +151,7 @@ public final class GroupsV1MigrationUtil {
return; return;
} }
Recipient recipient = Recipient.externalGroupExact(context, gv1Id); Recipient recipient = Recipient.externalGroupExact(gv1Id);
long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(recipient); long threadId = SignalDatabase.threads().getOrCreateThreadIdFor(recipient);
performLocalMigration(context, gv1Id, threadId, recipient); performLocalMigration(context, gv1Id, threadId, recipient);

Wyświetl plik

@ -84,7 +84,7 @@ public final class LiveGroup {
this.groupLink = new MutableLiveData<>(GroupLinkUrlAndStatus.NONE); this.groupLink = new MutableLiveData<>(GroupLinkUrlAndStatus.NONE);
} }
SignalExecutors.BOUNDED.execute(() -> liveRecipient.postValue(Recipient.externalGroupExact(context, groupId).live())); SignalExecutors.BOUNDED.execute(() -> liveRecipient.postValue(Recipient.externalGroupExact(groupId).live()));
} }
protected static LiveData<List<GroupMemberEntry.FullMember>> mapToFullMembers(@NonNull LiveData<GroupDatabase.GroupRecord> groupRecord) { protected static LiveData<List<GroupMemberEntry.FullMember>> mapToFullMembers(@NonNull LiveData<GroupDatabase.GroupRecord> groupRecord) {
@ -110,7 +110,7 @@ public final class LiveGroup {
return Stream.of(requestingMembersList) return Stream.of(requestingMembersList)
.map(requestingMember -> { .map(requestingMember -> {
Recipient recipient = Recipient.externalPush(ServiceId.fromByteString(requestingMember.getUuid()), null, false); Recipient recipient = Recipient.externalPush(ServiceId.fromByteString(requestingMember.getUuid()));
return new GroupMemberEntry.RequestingMember(recipient, selfAdmin); return new GroupMemberEntry.RequestingMember(recipient, selfAdmin);
}) })
.toList(); .toList();

Wyświetl plik

@ -109,7 +109,7 @@ public final class ChooseNewAdminActivity extends PassphraseRequiredActivity {
private void handleUpdateAndLeaveResult(@NonNull GroupChangeResult updateResult) { private void handleUpdateAndLeaveResult(@NonNull GroupChangeResult updateResult) {
if (updateResult.isSuccess()) { if (updateResult.isSuccess()) {
String title = Recipient.externalGroupExact(this, groupId).getDisplayName(this); String title = Recipient.externalGroupExact(groupId).getDisplayName(this);
Toast.makeText(this, getString(R.string.ChooseNewAdminActivity_you_left, title), Toast.LENGTH_LONG).show(); Toast.makeText(this, getString(R.string.ChooseNewAdminActivity_you_left, title), Toast.LENGTH_LONG).show();
startActivity(MainActivity.clearTop(this)); startActivity(MainActivity.clearTop(this));
finish(); finish();

Wyświetl plik

@ -449,7 +449,7 @@ public class GroupsV2StateProcessor {
return; return;
} }
Recipient groupRecipient = Recipient.externalGroupExact(context, groupId); Recipient groupRecipient = Recipient.externalGroupExact(groupId);
UUID selfUuid = serviceId.uuid(); UUID selfUuid = serviceId.uuid();
DecryptedGroup decryptedGroup = groupDatabase.requireGroup(groupId) DecryptedGroup decryptedGroup = groupDatabase.requireGroup(groupId)
@ -587,7 +587,7 @@ public class GroupsV2StateProcessor {
.filter(c -> c != null && c.getRevision() == revisionJoinedAt) .filter(c -> c != null && c.getRevision() == revisionJoinedAt)
.findFirst() .findFirst()
.map(c -> Optional.ofNullable(UuidUtil.fromByteStringOrNull(c.getEditor())) .map(c -> Optional.ofNullable(UuidUtil.fromByteStringOrNull(c.getEditor()))
.map(a -> Recipient.externalPush(ServiceId.fromByteStringOrNull(c.getEditor()), null, false))) .map(uuid -> Recipient.externalPush(ServiceId.from(uuid))))
.orElse(Optional.empty()); .orElse(Optional.empty());
if (addedByOptional.isPresent()) { if (addedByOptional.isPresent()) {
@ -603,7 +603,7 @@ public class GroupsV2StateProcessor {
} else if (addedBy.isSystemContact() || addedBy.isProfileSharing()) { } else if (addedBy.isSystemContact() || addedBy.isProfileSharing()) {
Log.i(TAG, "Group 'adder' is trusted. contact: " + addedBy.isSystemContact() + ", profileSharing: " + addedBy.isProfileSharing()); Log.i(TAG, "Group 'adder' is trusted. contact: " + addedBy.isSystemContact() + ", profileSharing: " + addedBy.isProfileSharing());
Log.i(TAG, "Added to a group and auto-enabling profile sharing"); Log.i(TAG, "Added to a group and auto-enabling profile sharing");
recipientDatabase.setProfileSharing(Recipient.externalGroupExact(context, groupId).getId(), true); recipientDatabase.setProfileSharing(Recipient.externalGroupExact(groupId).getId(), true);
} else { } else {
Log.i(TAG, "Added to a group, but not enabling profile sharing, as 'adder' is not trusted"); Log.i(TAG, "Added to a group, but not enabling profile sharing, as 'adder' is not trusted");
} }
@ -612,7 +612,7 @@ public class GroupsV2StateProcessor {
} }
} else if (selfAsPendingOptional.isPresent()) { } else if (selfAsPendingOptional.isPresent()) {
Optional<Recipient> addedBy = selfAsPendingOptional.flatMap(adder -> Optional.ofNullable(UuidUtil.fromByteStringOrNull(adder.getAddedByUuid())) Optional<Recipient> addedBy = selfAsPendingOptional.flatMap(adder -> Optional.ofNullable(UuidUtil.fromByteStringOrNull(adder.getAddedByUuid()))
.map(a -> Recipient.externalPush(ServiceId.fromByteStringOrNull(adder.getAddedByUuid()), null, false))); .map(uuid -> Recipient.externalPush(ServiceId.from(uuid))));
if (addedBy.isPresent() && addedBy.get().isBlocked()) { if (addedBy.isPresent() && addedBy.get().isBlocked()) {
Log.i(TAG, String.format( "Added to group %s by a blocked user %s. Leaving group.", groupId, addedBy.get().getId())); Log.i(TAG, String.format( "Added to group %s by a blocked user %s. Leaving group.", groupId, addedBy.get().getId()));
@ -698,7 +698,7 @@ public class GroupsV2StateProcessor {
} }
} else { } else {
MessageDatabase smsDatabase = SignalDatabase.sms(); MessageDatabase smsDatabase = SignalDatabase.sms();
RecipientId sender = RecipientId.from(editor.get(), null); RecipientId sender = RecipientId.from(editor.get());
IncomingTextMessage incoming = new IncomingTextMessage(sender, -1, timestamp, timestamp, timestamp, "", Optional.of(groupId), 0, false, null); IncomingTextMessage incoming = new IncomingTextMessage(sender, -1, timestamp, timestamp, timestamp, "", Optional.of(groupId), 0, false, null);
IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, decryptedGroupV2Context); IncomingGroupUpdateMessage groupMessage = new IncomingGroupUpdateMessage(incoming, decryptedGroupV2Context);
Optional<MessageDatabase.InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage); Optional<MessageDatabase.InsertResult> insertResult = smsDatabase.insertMessageInbox(groupMessage);

Wyświetl plik

@ -58,7 +58,7 @@ public class PushProcessMessageQueueJobMigration extends JobMigration {
Log.i(TAG, "Migrating a group message."); Log.i(TAG, "Migrating a group message.");
try { try {
GroupId groupId = GroupUtil.idFromGroupContext(content.getDataMessage().get().getGroupContext().get()); GroupId groupId = GroupUtil.idFromGroupContext(content.getDataMessage().get().getGroupContext().get());
Recipient recipient = Recipient.externalGroupExact(context, groupId); Recipient recipient = Recipient.externalGroupExact(groupId);
suffix = recipient.getId().toQueueKey(); suffix = recipient.getId().toQueueKey();
} catch (BadGroupIdException e) { } catch (BadGroupIdException e) {
@ -75,7 +75,7 @@ public class PushProcessMessageQueueJobMigration extends JobMigration {
GroupId exceptionGroup = GroupId.parseNullableOrThrow(data.getStringOrDefault("exception_groupId", null)); GroupId exceptionGroup = GroupId.parseNullableOrThrow(data.getStringOrDefault("exception_groupId", null));
if (exceptionGroup != null) { if (exceptionGroup != null) {
suffix = Recipient.externalGroupExact(context, exceptionGroup).getId().toQueueKey(); suffix = Recipient.externalGroupExact(exceptionGroup).getId().toQueueKey();
} else if (exceptionSender != null) { } else if (exceptionSender != null) {
suffix = Recipient.external(context, exceptionSender).getId().toQueueKey(); suffix = Recipient.external(context, exceptionSender).getId().toQueueKey();
} }

Wyświetl plik

@ -20,7 +20,7 @@ class LeaveGroupV2WorkerJob(parameters: Parameters, private val groupId: GroupId
constructor(groupId: GroupId.V2) : this( constructor(groupId: GroupId.V2) : this(
parameters = Parameters.Builder() parameters = Parameters.Builder()
.setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(ApplicationDependencies.getApplication(), groupId).id)) .setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(groupId).id))
.addConstraint(NetworkConstraint.KEY) .addConstraint(NetworkConstraint.KEY)
.setMaxAttempts(Parameters.UNLIMITED) .setMaxAttempts(Parameters.UNLIMITED)
.setMaxInstancesForQueue(2) .setMaxInstancesForQueue(2)
@ -41,7 +41,7 @@ class LeaveGroupV2WorkerJob(parameters: Parameters, private val groupId: GroupId
override fun onRun() { override fun onRun() {
Log.i(TAG, "Attempting to leave group $groupId") Log.i(TAG, "Attempting to leave group $groupId")
val groupRecipient = Recipient.externalGroupExact(ApplicationDependencies.getApplication(), groupId) val groupRecipient = Recipient.externalGroupExact(groupId)
GroupManager.leaveGroup(context, groupId) GroupManager.leaveGroup(context, groupId)

Wyświetl plik

@ -16,6 +16,7 @@ import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentPoin
import org.whispersystems.signalservice.api.messages.multidevice.DeviceContact import org.whispersystems.signalservice.api.messages.multidevice.DeviceContact
import org.whispersystems.signalservice.api.messages.multidevice.DeviceContactsInputStream import org.whispersystems.signalservice.api.messages.multidevice.DeviceContactsInputStream
import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage.VerifiedState import org.whispersystems.signalservice.api.messages.multidevice.VerifiedMessage.VerifiedState
import org.whispersystems.signalservice.api.push.SignalServiceAddress
import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException import org.whispersystems.signalservice.api.push.exceptions.MissingConfigurationException
import org.whispersystems.signalservice.api.util.AttachmentPointerUtil import org.whispersystems.signalservice.api.util.AttachmentPointerUtil
import java.io.File import java.io.File
@ -75,7 +76,7 @@ class MultiDeviceContactSyncJob(parameters: Parameters, private val attachmentPo
var contact: DeviceContact? = deviceContacts.read() var contact: DeviceContact? = deviceContacts.read()
while (contact != null) { while (contact != null) {
val recipient = Recipient.externalPush(contact.address.serviceId, contact.address.number.orElse(null), true) val recipient = Recipient.externalPush(SignalServiceAddress(contact.address.serviceId, contact.address.number.orElse(null)))
if (recipient.isSelf) { if (recipient.isSelf) {
contact = deviceContacts.read() contact = deviceContacts.read()

Wyświetl plik

@ -76,7 +76,7 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
Set<RecipientId> recipients = Stream.concat(Stream.of(memberUuids), Stream.of(pendingUuids)) Set<RecipientId> recipients = Stream.concat(Stream.of(memberUuids), Stream.of(pendingUuids))
.filter(uuid -> !UuidUtil.UNKNOWN_UUID.equals(uuid)) .filter(uuid -> !UuidUtil.UNKNOWN_UUID.equals(uuid))
.filter(uuid -> !SignalStore.account().requireAci().uuid().equals(uuid)) .filter(uuid -> !SignalStore.account().requireAci().uuid().equals(uuid))
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid), null, false)) .map(uuid -> Recipient.externalPush(ServiceId.from(uuid)))
.filter(recipient -> recipient.getRegistered() != RecipientDatabase.RegisteredState.NOT_REGISTERED) .filter(recipient -> recipient.getRegistered() != RecipientDatabase.RegisteredState.NOT_REGISTERED)
.map(Recipient::getId) .map(Recipient::getId)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
@ -84,7 +84,7 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
MessageGroupContext.GroupV2Properties properties = groupMessage.requireGroupV2Properties(); MessageGroupContext.GroupV2Properties properties = groupMessage.requireGroupV2Properties();
SignalServiceProtos.GroupContextV2 groupContext = properties.getGroupContext(); SignalServiceProtos.GroupContextV2 groupContext = properties.getGroupContext();
String queue = Recipient.externalGroupExact(context, groupId).getId().toQueueKey(); String queue = Recipient.externalGroupExact(groupId).getId().toQueueKey();
return new PushGroupSilentUpdateSendJob(new ArrayList<>(recipients), return new PushGroupSilentUpdateSendJob(new ArrayList<>(recipients),
recipients.size(), recipients.size(),
@ -133,7 +133,7 @@ public final class PushGroupSilentUpdateSendJob extends BaseJob {
GroupId.V2 groupId = GroupId.v2(GroupUtil.requireMasterKey(groupContextV2.getMasterKey().toByteArray())); GroupId.V2 groupId = GroupId.v2(GroupUtil.requireMasterKey(groupContextV2.getMasterKey().toByteArray()));
if (Recipient.externalGroupExact(context, groupId).isBlocked()) { if (Recipient.externalGroupExact(groupId).isBlocked()) {
Log.i(TAG, "Not updating group state for blocked group " + groupId); Log.i(TAG, "Not updating group state for blocked group " + groupId);
return; return;
} }

Wyświetl plik

@ -126,7 +126,7 @@ public final class PushProcessMessageJob extends BaseJob {
try { try {
GroupId groupId = GroupUtil.idFromGroupContext(signalServiceGroupContext); GroupId groupId = GroupUtil.idFromGroupContext(signalServiceGroupContext);
queueName = getQueueName(Recipient.externalPossiblyMigratedGroup(context, groupId).getId()); queueName = getQueueName(Recipient.externalPossiblyMigratedGroup(groupId).getId());
if (groupId.isV2()) { if (groupId.isV2()) {
int localRevision = SignalDatabase.groups().getGroupV2Revision(groupId.requireV2()); int localRevision = SignalDatabase.groups().getGroupV2Revision(groupId.requireV2());
@ -143,12 +143,12 @@ public final class PushProcessMessageJob extends BaseJob {
Log.w(TAG, "Bad groupId! Using default queue. ID: " + content.getTimestamp()); Log.w(TAG, "Bad groupId! Using default queue. ID: " + content.getTimestamp());
} }
} else if (content.getSyncMessage().isPresent() && content.getSyncMessage().get().getSent().isPresent() && content.getSyncMessage().get().getSent().get().getDestination().isPresent()) { } else if (content.getSyncMessage().isPresent() && content.getSyncMessage().get().getSent().isPresent() && content.getSyncMessage().get().getSent().get().getDestination().isPresent()) {
queueName = getQueueName(RecipientId.fromHighTrust(content.getSyncMessage().get().getSent().get().getDestination().get())); queueName = getQueueName(RecipientId.from(content.getSyncMessage().get().getSent().get().getDestination().get()));
} else { } else {
queueName = getQueueName(RecipientId.fromHighTrust(content.getSender())); queueName = getQueueName(RecipientId.from(content.getSender()));
} }
} else if (exceptionMetadata != null) { } else if (exceptionMetadata != null) {
Recipient recipient = exceptionMetadata.getGroupId() != null ? Recipient.externalPossiblyMigratedGroup(context, exceptionMetadata.getGroupId()) Recipient recipient = exceptionMetadata.getGroupId() != null ? Recipient.externalPossiblyMigratedGroup(exceptionMetadata.getGroupId())
: Recipient.external(context, exceptionMetadata.getSender()); : Recipient.external(context, exceptionMetadata.getSender());
queueName = getQueueName(recipient.getId()); queueName = getQueueName(recipient.getId());
} }

Wyświetl plik

@ -7,7 +7,6 @@ import org.signal.core.util.logging.Log;
import org.signal.libsignal.zkgroup.VerificationFailedException; import org.signal.libsignal.zkgroup.VerificationFailedException;
import org.thoughtcrime.securesms.database.GroupDatabase; import org.thoughtcrime.securesms.database.GroupDatabase;
import org.thoughtcrime.securesms.database.SignalDatabase; import org.thoughtcrime.securesms.database.SignalDatabase;
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
import org.thoughtcrime.securesms.groups.GroupChangeBusyException; import org.thoughtcrime.securesms.groups.GroupChangeBusyException;
import org.thoughtcrime.securesms.groups.GroupId; import org.thoughtcrime.securesms.groups.GroupId;
import org.thoughtcrime.securesms.groups.GroupManager; import org.thoughtcrime.securesms.groups.GroupManager;
@ -44,7 +43,7 @@ final class RequestGroupV2InfoWorkerJob extends BaseJob {
@WorkerThread @WorkerThread
RequestGroupV2InfoWorkerJob(@NonNull GroupId.V2 groupId, int toRevision) { RequestGroupV2InfoWorkerJob(@NonNull GroupId.V2 groupId, int toRevision) {
this(new Parameters.Builder() this(new Parameters.Builder()
.setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(ApplicationDependencies.getApplication(), groupId).getId())) .setQueue(PushProcessMessageJob.getQueueName(Recipient.externalGroupExact(groupId).getId()))
.addConstraint(NetworkConstraint.KEY) .addConstraint(NetworkConstraint.KEY)
.setLifespan(TimeUnit.DAYS.toMillis(1)) .setLifespan(TimeUnit.DAYS.toMillis(1))
.setMaxAttempts(Parameters.UNLIMITED) .setMaxAttempts(Parameters.UNLIMITED)
@ -87,7 +86,7 @@ final class RequestGroupV2InfoWorkerJob extends BaseJob {
return; return;
} }
if (Recipient.externalGroupExact(context, groupId).isBlocked()) { if (Recipient.externalGroupExact(groupId).isBlocked()) {
Log.i(TAG, "Not fetching group info for blocked group " + groupId); Log.i(TAG, "Not fetching group info for blocked group " + groupId);
return; return;
} }

Wyświetl plik

@ -31,7 +31,6 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.signalservice.api.SignalSessionLock; import org.whispersystems.signalservice.api.SignalSessionLock;
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope; import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext; import org.whispersystems.signalservice.api.messages.SignalServiceGroupContext;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import java.io.Closeable; import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
@ -89,7 +88,7 @@ public class IncomingMessageProcessor {
} }
if (envelope.hasSourceUuid()) { if (envelope.hasSourceUuid()) {
Recipient.externalHighTrustPush(context, envelope.getSourceAddress()); Recipient.externalPush(envelope.getSourceAddress());
} }
if (envelope.isReceipt()) { if (envelope.isReceipt()) {
@ -165,7 +164,7 @@ public class IncomingMessageProcessor {
} }
private void processReceipt(@NonNull SignalServiceEnvelope envelope) { private void processReceipt(@NonNull SignalServiceEnvelope envelope) {
Recipient sender = Recipient.externalHighTrustPush(context, envelope.getSourceAddress()); Recipient sender = Recipient.externalPush(envelope.getSourceAddress());
Log.i(TAG, "Received server receipt. Sender: " + sender.getId() + ", Device: " + envelope.getSourceDevice() + ", Timestamp: " + envelope.getTimestamp()); Log.i(TAG, "Received server receipt. Sender: " + sender.getId() + ", Device: " + envelope.getSourceDevice() + ", Timestamp: " + envelope.getTimestamp());
mmsSmsDatabase.incrementDeliveryReceiptCount(new SyncMessageId(sender.getId(), envelope.getTimestamp()), System.currentTimeMillis()); mmsSmsDatabase.incrementDeliveryReceiptCount(new SyncMessageId(sender.getId(), envelope.getTimestamp()), System.currentTimeMillis());
@ -185,7 +184,7 @@ public class IncomingMessageProcessor {
GroupId groupId = GroupUtil.idFromGroupContext(groupContext); GroupId groupId = GroupUtil.idFromGroupContext(groupContext);
if (groupId.isV2()) { if (groupId.isV2()) {
String queueName = PushProcessMessageJob.getQueueName(Recipient.externalPossiblyMigratedGroup(context, groupId).getId()); String queueName = PushProcessMessageJob.getQueueName(Recipient.externalPossiblyMigratedGroup(groupId).getId());
GroupDatabase groupDatabase = SignalDatabase.groups(); GroupDatabase groupDatabase = SignalDatabase.groups();
return !jobManager.isQueueEmpty(queueName) || return !jobManager.isQueueEmpty(queueName) ||
@ -199,7 +198,7 @@ public class IncomingMessageProcessor {
return false; return false;
} }
} else if (result.getContent() != null) { } else if (result.getContent() != null) {
RecipientId recipientId = RecipientId.fromHighTrust(result.getContent().getSender()); RecipientId recipientId = RecipientId.from(result.getContent().getSender());
String queueKey = PushProcessMessageJob.getQueueName(recipientId); String queueKey = PushProcessMessageJob.getQueueName(recipientId);
return !jobManager.isQueueEmpty(queueKey); return !jobManager.isQueueEmpty(queueKey);

Wyświetl plik

@ -234,7 +234,7 @@ public final class MessageContentProcessor {
if (messageState == MessageState.DECRYPTED_OK) { if (messageState == MessageState.DECRYPTED_OK) {
if (content != null) { if (content != null) {
Recipient senderRecipient = Recipient.externalHighTrustPush(context, content.getSender()); Recipient senderRecipient = Recipient.externalPush(content.getSender());
handleMessage(content, timestamp, senderRecipient, optionalSmsMessageId); handleMessage(content, timestamp, senderRecipient, optionalSmsMessageId);
@ -1103,7 +1103,7 @@ public final class MessageContentProcessor {
recipient = Recipient.externalPush(response.getPerson().get()); recipient = Recipient.externalPush(response.getPerson().get());
} else if (response.getGroupId().isPresent()) { } else if (response.getGroupId().isPresent()) {
GroupId groupId = GroupId.v1(response.getGroupId().get()); GroupId groupId = GroupId.v1(response.getGroupId().get());
recipient = Recipient.externalPossiblyMigratedGroup(context, groupId); recipient = Recipient.externalPossiblyMigratedGroup(groupId);
} else { } else {
warn("Message request response was missing a thread recipient! Skipping."); warn("Message request response was missing a thread recipient! Skipping.");
return; return;
@ -1562,7 +1562,7 @@ public final class MessageContentProcessor {
database.beginTransaction(); database.beginTransaction();
try { try {
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null); RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId());
ParentStoryId parentStoryId; ParentStoryId parentStoryId;
QuoteModel quoteModel = null; QuoteModel quoteModel = null;
long expiresInMillis = 0; long expiresInMillis = 0;
@ -1656,7 +1656,7 @@ public final class MessageContentProcessor {
database.beginTransaction(); database.beginTransaction();
try { try {
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null); RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId());
ParentStoryId parentStoryId; ParentStoryId parentStoryId;
QuoteModel quoteModel = null; QuoteModel quoteModel = null;
long expiresInMillis = 0L; long expiresInMillis = 0L;
@ -1937,7 +1937,7 @@ public final class MessageContentProcessor {
Recipient recipient = getSyncMessageDestination(message); Recipient recipient = getSyncMessageDestination(message);
QuoteModel quoteModel = null; QuoteModel quoteModel = null;
long expiresInMillis = 0L; long expiresInMillis = 0L;
RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId(), null); RecipientId storyAuthorRecipient = RecipientId.from(storyContext.getAuthorServiceId());
MessageId storyMessageId = database.getStoryId(storyAuthorRecipient, storyContext.getSentTimestamp()); MessageId storyMessageId = database.getStoryId(storyAuthorRecipient, storyContext.getSentTimestamp());
MmsMessageRecord story = (MmsMessageRecord) database.getMessageRecord(storyMessageId.getId()); MmsMessageRecord story = (MmsMessageRecord) database.getMessageRecord(storyMessageId.getId());
Recipient threadRecipient = SignalDatabase.threads().getRecipientForThreadId(story.getThreadId()); Recipient threadRecipient = SignalDatabase.threads().getRecipientForThreadId(story.getThreadId());
@ -2552,7 +2552,7 @@ public final class MessageContentProcessor {
@NonNull SignalServiceDataMessage message, @NonNull SignalServiceDataMessage message,
@NonNull MessageId messageId) @NonNull MessageId messageId)
{ {
ApplicationDependencies.getJobManager().add(new SendDeliveryReceiptJob(RecipientId.fromHighTrust(content.getSender()), message.getTimestamp(), messageId)); ApplicationDependencies.getJobManager().add(new SendDeliveryReceiptJob(RecipientId.from(content.getSender()), message.getTimestamp(), messageId));
} }
private void handleViewedReceipt(@NonNull SignalServiceContent content, private void handleViewedReceipt(@NonNull SignalServiceContent content,
@ -2666,7 +2666,7 @@ public final class MessageContentProcessor {
return; return;
} }
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(context, groupId); Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId);
threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient); threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient);
} else { } else {
@ -2990,7 +2990,7 @@ public final class MessageContentProcessor {
List<Mention> mentions = new ArrayList<>(signalServiceMentions.size()); List<Mention> mentions = new ArrayList<>(signalServiceMentions.size());
for (SignalServiceDataMessage.Mention mention : signalServiceMentions) { for (SignalServiceDataMessage.Mention mention : signalServiceMentions) {
mentions.add(new Mention(Recipient.externalPush(mention.getServiceId(), null, false).getId(), mention.getStart(), mention.getLength())); mentions.add(new Mention(Recipient.externalPush(mention.getServiceId()).getId(), mention.getStart(), mention.getLength()));
} }
return mentions; return mentions;
@ -3026,14 +3026,14 @@ public final class MessageContentProcessor {
private Recipient getMessageDestination(@NonNull SignalServiceContent content) throws BadGroupIdException { private Recipient getMessageDestination(@NonNull SignalServiceContent content) throws BadGroupIdException {
SignalServiceDataMessage message = content.getDataMessage().orElse(null); SignalServiceDataMessage message = content.getDataMessage().orElse(null);
return getGroupRecipient(message != null ? message.getGroupContext() : Optional.empty()).orElseGet(() -> Recipient.externalHighTrustPush(context, content.getSender())); return getGroupRecipient(message != null ? message.getGroupContext() : Optional.empty()).orElseGet(() -> Recipient.externalPush(content.getSender()));
} }
private Optional<Recipient> getGroupRecipient(Optional<SignalServiceGroupContext> message) private Optional<Recipient> getGroupRecipient(Optional<SignalServiceGroupContext> message)
throws BadGroupIdException throws BadGroupIdException
{ {
if (message.isPresent()) { if (message.isPresent()) {
return Optional.of(Recipient.externalPossiblyMigratedGroup(context, GroupUtil.idFromGroupContext(message.get()))); return Optional.of(Recipient.externalPossiblyMigratedGroup(GroupUtil.idFromGroupContext(message.get())));
} }
return Optional.empty(); return Optional.empty();
} }
@ -3093,7 +3093,7 @@ public final class MessageContentProcessor {
if (content.getTypingMessage().get().getGroupId().isPresent()) { if (content.getTypingMessage().get().getGroupId().isPresent()) {
GroupId groupId = GroupId.push(content.getTypingMessage().get().getGroupId().get()); GroupId groupId = GroupId.push(content.getTypingMessage().get().getGroupId().get());
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(context, groupId); Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId);
if (groupRecipient.isBlocked() || !groupRecipient.isActiveGroup()) { if (groupRecipient.isBlocked() || !groupRecipient.isActiveGroup()) {
return true; return true;

Wyświetl plik

@ -164,7 +164,7 @@ public final class MessageDecryptionUtil {
long threadId; long threadId;
if (groupId.isPresent()) { if (groupId.isPresent()) {
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(context, groupId.get()); Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId.get());
threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient); threadId = SignalDatabase.threads().getOrCreateThreadIdFor(groupRecipient);
} else { } else {
threadId = SignalDatabase.threads().getOrCreateThreadIdFor(sender); threadId = SignalDatabase.threads().getOrCreateThreadIdFor(sender);

Wyświetl plik

@ -132,7 +132,7 @@ public final class MessageGroupContext {
return Stream.of(groupContext.getMembersList()) return Stream.of(groupContext.getMembersList())
.map(GroupContext.Member::getE164) .map(GroupContext.Member::getE164)
.withoutNulls() .withoutNulls()
.map(RecipientId::fromExternalPush) .map(RecipientId::fromE164)
.filterNot(selfId::equals) .filterNot(selfId::equals)
.toList(); .toList();
} }
@ -191,7 +191,7 @@ public final class MessageGroupContext {
List<RecipientId> members = new ArrayList<>(decryptedGroupV2Context.getGroupState().getMembersCount()); List<RecipientId> members = new ArrayList<>(decryptedGroupV2Context.getGroupState().getMembersCount());
for (DecryptedMember member : decryptedGroupV2Context.getGroupState().getMembersList()) { for (DecryptedMember member : decryptedGroupV2Context.getGroupState().getMembersList()) {
RecipientId recipient = RecipientId.from(ServiceId.fromByteString(member.getUuid()), null); RecipientId recipient = RecipientId.from(ServiceId.fromByteString(member.getUuid()));
if (!Recipient.self().getId().equals(recipient)) { if (!Recipient.self().getId().equals(recipient)) {
members.add(recipient); members.add(recipient);
} }

Wyświetl plik

@ -163,7 +163,7 @@ public final class LiveRecipientCache {
} }
if (selfId == null) { if (selfId == null) {
selfId = recipientDatabase.getAndPossiblyMerge(localAci, localE164, true); selfId = recipientDatabase.getAndPossiblyMerge(localAci, localE164);
} }
synchronized (localRecipientId) { synchronized (localRecipientId) {

Wyświetl plik

@ -199,19 +199,18 @@ public class Recipient {
*/ */
@WorkerThread @WorkerThread
public static @NonNull Recipient externalUsername(@NonNull ServiceId serviceId, @NonNull String username) { public static @NonNull Recipient externalUsername(@NonNull ServiceId serviceId, @NonNull String username) {
Recipient recipient = externalPush(serviceId, null, false); Recipient recipient = externalPush(serviceId);
SignalDatabase.recipients().setUsername(recipient.getId(), username); SignalDatabase.recipients().setUsername(recipient.getId(), username);
return recipient; return recipient;
} }
/** /**
* Returns a fully-populated {@link Recipient} based off of a {@link SignalServiceAddress}, * Returns a fully-populated {@link Recipient} based off of a {@link SignalServiceAddress},
* creating one in the database if necessary. Convenience overload of * creating one in the database if necessary.
* {@link #externalPush(ServiceId, String, boolean)}
*/ */
@WorkerThread @WorkerThread
public static @NonNull Recipient externalPush(@NonNull SignalServiceAddress signalServiceAddress) { public static @NonNull Recipient externalPush(@NonNull SignalServiceAddress signalServiceAddress) {
return externalPush(signalServiceAddress.getServiceId(), signalServiceAddress.getNumber().orElse(null), false); return externalPush(signalServiceAddress.getServiceId(), signalServiceAddress.getNumber().orElse(null));
} }
/** /**
@ -222,46 +221,38 @@ public class Recipient {
@WorkerThread @WorkerThread
public static @NonNull Recipient externalGV1Member(@NonNull SignalServiceAddress address) { public static @NonNull Recipient externalGV1Member(@NonNull SignalServiceAddress address) {
if (address.getNumber().isPresent()) { if (address.getNumber().isPresent()) {
return externalPush(null, address.getNumber().get(), false); return externalPush(null, address.getNumber().get());
} else { } else {
return externalPush(address.getServiceId(), null, false); return externalPush(address.getServiceId());
} }
} }
/** /**
* Returns a fully-populated {@link Recipient} based off of a {@link SignalServiceAddress}, * Returns a fully-populated {@link Recipient} based off of a ServiceId, creating one
* creating one in the database if necessary. This should only used for high-trust sources, * in the database if necessary.
* which are limited to:
* - Envelopes
* - UD Certs
* - CDS
* - Storage Service
*/ */
@WorkerThread @WorkerThread
public static @NonNull Recipient externalHighTrustPush(@NonNull Context context, @NonNull SignalServiceAddress signalServiceAddress) { public static @NonNull Recipient externalPush(@NonNull ServiceId serviceId) {
return externalPush(signalServiceAddress.getServiceId(), signalServiceAddress.getNumber().orElse(null), true); return externalPush(serviceId, null);
} }
/** /**
* Returns a fully-populated {@link Recipient} based off of an ACI and phone number, creating one * Returns a fully-populated {@link Recipient} based off of a ServiceId and phone number, creating one
* in the database if necessary. We want both piece of information so we're able to associate them * in the database if necessary. We want both piece of information so we're able to associate them
* both together, depending on which are available. * both together, depending on which are available.
* *
* In particular, while we'll eventually get the ACI of a user created via a phone number * In particular, while we'll eventually get the ACI of a user created via a phone number
* (through a directory sync), the only way we can store the phone number is by retrieving it from * (through a directory sync), the only way we can store the phone number is by retrieving it from
* sent messages and whatnot. So we should store it when available. * sent messages and whatnot. So we should store it when available.
*
* @param highTrust This should only be set to true if the source of the E164-ACI pairing is one
* that can be trusted as accurate (like an envelope).
*/ */
@WorkerThread @WorkerThread
public static @NonNull Recipient externalPush(@Nullable ServiceId serviceId, @Nullable String e164, boolean highTrust) { static @NonNull Recipient externalPush(@Nullable ServiceId serviceId, @Nullable String e164) {
if (ServiceId.UNKNOWN.equals(serviceId)) { if (ServiceId.UNKNOWN.equals(serviceId)) {
throw new AssertionError(); throw new AssertionError();
} }
RecipientDatabase db = SignalDatabase.recipients(); RecipientDatabase db = SignalDatabase.recipients();
RecipientId recipientId = db.getAndPossiblyMerge(serviceId, e164, highTrust); RecipientId recipientId = db.getAndPossiblyMerge(serviceId, e164);
Recipient resolved = resolved(recipientId); Recipient resolved = resolved(recipientId);
@ -269,11 +260,11 @@ public class Recipient {
Log.w(TAG, "Resolved " + recipientId + ", but got back a recipient with " + resolved.getId()); Log.w(TAG, "Resolved " + recipientId + ", but got back a recipient with " + resolved.getId());
} }
if (highTrust && !resolved.isRegistered() && serviceId != null) { if (!resolved.isRegistered() && serviceId != null) {
Log.w(TAG, "External high-trust push was locally marked unregistered. Marking as registered."); Log.w(TAG, "External push was locally marked unregistered. Marking as registered.");
db.markRegistered(recipientId, serviceId); db.markRegistered(recipientId, serviceId);
} else if (highTrust && !resolved.isRegistered()) { } else if (!resolved.isRegistered()) {
Log.w(TAG, "External high-trust push was locally marked unregistered, but we don't have an ACI, so we can't do anything.", new Throwable()); Log.w(TAG, "External push was locally marked unregistered, but we don't have an ACI, so we can't do anything.", new Throwable());
} }
return resolved; return resolved;
@ -287,7 +278,7 @@ public class Recipient {
* (This may seem strange, but apparently some devices are returning valid UUIDs for contacts) * (This may seem strange, but apparently some devices are returning valid UUIDs for contacts)
*/ */
@WorkerThread @WorkerThread
public static @NonNull Recipient externalContact(@NonNull Context context, @NonNull String identifier) { public static @NonNull Recipient externalContact(@NonNull String identifier) {
RecipientDatabase db = SignalDatabase.recipients(); RecipientDatabase db = SignalDatabase.recipients();
RecipientId id = null; RecipientId id = null;
@ -308,11 +299,11 @@ public class Recipient {
* *
* Important: This will throw an exception if the groupId you're using could have been migrated. * Important: This will throw an exception if the groupId you're using could have been migrated.
* If you're dealing with inbound data, you should be using * If you're dealing with inbound data, you should be using
* {@link #externalPossiblyMigratedGroup(Context, GroupId)}, or checking the database before * {@link #externalPossiblyMigratedGroup(GroupId)}, or checking the database before
* calling this method. * calling this method.
*/ */
@WorkerThread @WorkerThread
public static @NonNull Recipient externalGroupExact(@NonNull Context context, @NonNull GroupId groupId) { public static @NonNull Recipient externalGroupExact(@NonNull GroupId groupId) {
return Recipient.resolved(SignalDatabase.recipients().getOrInsertFromGroupId(groupId)); return Recipient.resolved(SignalDatabase.recipients().getOrInsertFromGroupId(groupId));
} }
@ -327,7 +318,7 @@ public class Recipient {
* You should be very cautious when using the groupId on the returned recipient. * You should be very cautious when using the groupId on the returned recipient.
*/ */
@WorkerThread @WorkerThread
public static @NonNull Recipient externalPossiblyMigratedGroup(@NonNull Context context, @NonNull GroupId groupId) { public static @NonNull Recipient externalPossiblyMigratedGroup(@NonNull GroupId groupId) {
return Recipient.resolved(SignalDatabase.recipients().getOrInsertFromPossiblyMigratedGroupId(groupId)); return Recipient.resolved(SignalDatabase.recipients().getOrInsertFromPossiblyMigratedGroupId(groupId));
} }
@ -337,7 +328,7 @@ public class Recipient {
* or serialized groupId. * or serialized groupId.
* *
* If the identifier is a UUID of a Signal user, prefer using * If the identifier is a UUID of a Signal user, prefer using
* {@link #externalPush(ServiceId, String, boolean)} or its overload, as this will let us associate * {@link #externalPush(ServiceId, String)} or its overload, as this will let us associate
* the phone number with the recipient. * the phone number with the recipient.
*/ */
@WorkerThread @WorkerThread

Wyświetl plik

@ -56,7 +56,17 @@ public class RecipientId implements Parcelable, Comparable<RecipientId>, Databas
@AnyThread @AnyThread
public static @NonNull RecipientId from(@NonNull SignalServiceAddress address) { public static @NonNull RecipientId from(@NonNull SignalServiceAddress address) {
return from(address.getServiceId(), address.getNumber().orElse(null), false); return from(address.getServiceId(), address.getNumber().orElse(null));
}
@AnyThread
public static @NonNull RecipientId from(@NonNull ServiceId serviceId) {
return from(serviceId, null);
}
@AnyThread
public static @NonNull RecipientId fromE164(@NonNull String identifier) {
return from(null, identifier);
} }
/** /**
@ -65,35 +75,17 @@ public class RecipientId implements Parcelable, Comparable<RecipientId>, Databas
* @param identifier A UUID or e164 * @param identifier A UUID or e164
*/ */
@AnyThread @AnyThread
public static @NonNull RecipientId fromExternalPush(@NonNull String identifier) { public static @NonNull RecipientId fromSidOrE164(@NonNull String identifier) {
if (UuidUtil.isUuid(identifier)) { if (UuidUtil.isUuid(identifier)) {
return from(ServiceId.parseOrThrow(identifier), null); return from(ServiceId.parseOrThrow(identifier));
} else { } else {
return from(null, identifier); return from(null, identifier);
} }
} }
/**
* Indicates that the pairing is from a high-trust source.
* See {@link Recipient#externalHighTrustPush(Context, SignalServiceAddress)}
*/
@AnyThread
public static @NonNull RecipientId fromHighTrust(@NonNull SignalServiceAddress address) {
return from(address.getServiceId(), address.getNumber().orElse(null), true);
}
/**
* Always supply both {@param uuid} and {@param e164} if you have both.
*/
@AnyThread @AnyThread
@SuppressLint("WrongThread") @SuppressLint("WrongThread")
public static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164) { private static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164) {
return from(serviceId, e164, false);
}
@AnyThread
@SuppressLint("WrongThread")
private static @NonNull RecipientId from(@Nullable ServiceId serviceId, @Nullable String e164, boolean highTrust) {
if (serviceId != null && serviceId.isUnknown()) { if (serviceId != null && serviceId.isUnknown()) {
return RecipientId.UNKNOWN; return RecipientId.UNKNOWN;
} }
@ -101,7 +93,7 @@ public class RecipientId implements Parcelable, Comparable<RecipientId>, Databas
RecipientId recipientId = RecipientIdCache.INSTANCE.get(serviceId, e164); RecipientId recipientId = RecipientIdCache.INSTANCE.get(serviceId, e164);
if (recipientId == null) { if (recipientId == null) {
Recipient recipient = Recipient.externalPush(serviceId, e164, highTrust); Recipient recipient = Recipient.externalPush(serviceId, e164);
RecipientIdCache.INSTANCE.put(recipient); RecipientIdCache.INSTANCE.put(recipient);
recipientId = recipient.getId(); recipientId = recipient.getId();
} }

Wyświetl plik

@ -150,7 +150,7 @@ public final class RegistrationRepository {
} }
RecipientDatabase recipientDatabase = SignalDatabase.recipients(); RecipientDatabase recipientDatabase = SignalDatabase.recipients();
RecipientId selfId = Recipient.externalPush(aci, registrationData.getE164(), true).getId(); RecipientId selfId = Recipient.externalPush(new SignalServiceAddress(aci, registrationData.getE164())).getId();
recipientDatabase.setProfileSharing(selfId, true); recipientDatabase.setProfileSharing(selfId, true);
recipientDatabase.markRegisteredOrThrow(selfId, aci); recipientDatabase.markRegisteredOrThrow(selfId, aci);

Wyświetl plik

@ -83,7 +83,7 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor {
seen.add(Recipient.self()); seen.add(Recipient.self());
for (GroupCall.RemoteDeviceState device : remoteDeviceStates) { for (GroupCall.RemoteDeviceState device : remoteDeviceStates) {
Recipient recipient = Recipient.externalPush(ServiceId.from(device.getUserId()), null, false); Recipient recipient = Recipient.externalPush(ServiceId.from(device.getUserId()));
CallParticipantId callParticipantId = new CallParticipantId(device.getDemuxId(), recipient.getId()); CallParticipantId callParticipantId = new CallParticipantId(device.getDemuxId(), recipient.getId());
CallParticipant callParticipant = participants.get(callParticipantId); CallParticipant callParticipant = participants.get(callParticipantId);

Wyświetl plik

@ -114,7 +114,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor {
} }
List<Recipient> callParticipants = Stream.of(peekInfo.getJoinedMembers()) List<Recipient> callParticipants = Stream.of(peekInfo.getJoinedMembers())
.map(uuid -> Recipient.externalPush(ServiceId.from(uuid), null, false)) .map(uuid -> Recipient.externalPush(ServiceId.from(uuid)))
.toList(); .toList();
WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder() WebRtcServiceStateBuilder.CallInfoStateBuilder builder = currentState.builder()

Wyświetl plik

@ -138,7 +138,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
.changeCallSetupState(RemotePeer.GROUP_CALL_ID) .changeCallSetupState(RemotePeer.GROUP_CALL_ID)
.isRemoteVideoOffer(true) .isRemoteVideoOffer(true)
.ringId(ringId) .ringId(ringId)
.ringerRecipient(Recipient.externalPush(ServiceId.from(uuid), null, false)) .ringerRecipient(Recipient.externalPush(ServiceId.from(uuid)))
.commit() .commit()
.changeCallInfoState() .changeCallInfoState()
.activePeer(new RemotePeer(currentState.getCallInfoState().getCallRecipient().getId(), RemotePeer.GROUP_CALL_ID)) .activePeer(new RemotePeer(currentState.getCallInfoState().getCallRecipient().getId(), RemotePeer.GROUP_CALL_ID))

Wyświetl plik

@ -639,7 +639,7 @@ private void processStateless(@NonNull Function1<WebRtcEphemeralState, WebRtcEph
SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOpaque(opaqueMessage, true, null); SignalServiceCallMessage callMessage = SignalServiceCallMessage.forOpaque(opaqueMessage, true, null);
networkExecutor.execute(() -> { networkExecutor.execute(() -> {
Recipient recipient = Recipient.resolved(RecipientId.from(ServiceId.from(uuid), null)); Recipient recipient = Recipient.resolved(RecipientId.from(ServiceId.from(uuid)));
if (recipient.isBlocked()) { if (recipient.isBlocked()) {
return; return;
} }

Wyświetl plik

@ -88,8 +88,8 @@ public final class GroupsV2UpdateMessageProducerTest {
producer = new GroupsV2UpdateMessageProducer(ApplicationProvider.getApplicationContext(), new ServiceIds(ACI.from(you), PNI.from(UUID.randomUUID())), null); producer = new GroupsV2UpdateMessageProducer(ApplicationProvider.getApplicationContext(), new ServiceIds(ACI.from(you), PNI.from(UUID.randomUUID())), null);
recipientIdMockedStatic.when(() -> RecipientId.from(ServiceId.from(alice), null)).thenReturn(aliceId); recipientIdMockedStatic.when(() -> RecipientId.from(ServiceId.from(alice))).thenReturn(aliceId);
recipientIdMockedStatic.when(() -> RecipientId.from(ServiceId.from(bob), null)).thenReturn(bobId); recipientIdMockedStatic.when(() -> RecipientId.from(ServiceId.from(bob))).thenReturn(bobId);
recipientMockedStatic.when(() -> Recipient.resolved(aliceId)).thenReturn(aliceRecipient); recipientMockedStatic.when(() -> Recipient.resolved(aliceId)).thenReturn(aliceRecipient);
recipientMockedStatic.when(() -> Recipient.resolved(bobId)).thenReturn(bobRecipient); recipientMockedStatic.when(() -> Recipient.resolved(bobId)).thenReturn(bobRecipient);
} }