mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Remove GV1 migration support.
This commit is contained in:
committed by
Greyson Parrelli
parent
213d996168
commit
34a228f85e
@@ -44,7 +44,6 @@ import org.thoughtcrime.securesms.groups.BadGroupIdException
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.GroupId.Push
|
||||
import org.thoughtcrime.securesms.groups.GroupMigrationMembershipChange
|
||||
import org.thoughtcrime.securesms.groups.GroupsV1MigratedCache
|
||||
import org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor
|
||||
import org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
@@ -658,15 +657,9 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
|
||||
|
||||
@JvmOverloads
|
||||
@CheckReturnValue
|
||||
fun create(groupMasterKey: GroupMasterKey, groupState: DecryptedGroup, force: Boolean = false): GroupId.V2? {
|
||||
fun create(groupMasterKey: GroupMasterKey, groupState: DecryptedGroup): GroupId.V2? {
|
||||
val groupId = GroupId.v2(groupMasterKey)
|
||||
|
||||
if (!force && GroupsV1MigratedCache.hasV1Group(groupId)) {
|
||||
throw MissedGroupMigrationInsertException(groupId)
|
||||
} else if (force) {
|
||||
Log.w(TAG, "Forcing the creation of a group even though we already have a V1 ID!")
|
||||
}
|
||||
|
||||
return if (create(groupId = groupId, title = groupState.title, memberCollection = emptyList(), avatar = null, groupMasterKey = groupMasterKey, groupState = groupState)) {
|
||||
groupId
|
||||
} else {
|
||||
@@ -680,9 +673,6 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
|
||||
*/
|
||||
fun fixMissingMasterKey(groupMasterKey: GroupMasterKey) {
|
||||
val groupId = GroupId.v2(groupMasterKey)
|
||||
if (GroupsV1MigratedCache.hasV1Group(groupId)) {
|
||||
Log.w(TAG, "There already exists a V1 group that should be migrated into this group. But if the recipient already exists, there's not much we can do here.")
|
||||
}
|
||||
|
||||
writableDatabase.withinTransaction { db ->
|
||||
val updated = db
|
||||
@@ -697,8 +687,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
|
||||
groupMasterKey,
|
||||
DecryptedGroup.Builder()
|
||||
.revision(GroupsV2StateProcessor.RESTORE_PLACEHOLDER_REVISION)
|
||||
.build(),
|
||||
true
|
||||
.build()
|
||||
)
|
||||
} else {
|
||||
Log.w(TAG, "Had a group entry, but it was missing a master key. Updated.")
|
||||
@@ -1526,5 +1515,4 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
|
||||
}
|
||||
|
||||
class LegacyGroupInsertException(id: GroupId?) : IllegalStateException("Tried to create a new GV1 entry when we already had a migrated GV2! $id")
|
||||
class MissedGroupMigrationInsertException(id: GroupId?) : IllegalStateException("Tried to create a new GV2 entry when we already had a V1 group that mapped to the new ID! $id")
|
||||
}
|
||||
|
||||
@@ -56,7 +56,6 @@ import org.thoughtcrime.securesms.conversation.colors.ChatColors.Id.Companion.fo
|
||||
import org.thoughtcrime.securesms.conversation.colors.ChatColorsMapper.getChatColors
|
||||
import org.thoughtcrime.securesms.crypto.ProfileKeyUtil
|
||||
import org.thoughtcrime.securesms.database.GroupTable.LegacyGroupInsertException
|
||||
import org.thoughtcrime.securesms.database.GroupTable.MissedGroupMigrationInsertException
|
||||
import org.thoughtcrime.securesms.database.GroupTable.ShowAsStoryState
|
||||
import org.thoughtcrime.securesms.database.IdentityTable.VerifiedStatus
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase.Companion.groups
|
||||
@@ -80,7 +79,6 @@ import org.thoughtcrime.securesms.groups.BadGroupIdException
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.GroupId.V1
|
||||
import org.thoughtcrime.securesms.groups.GroupId.V2
|
||||
import org.thoughtcrime.securesms.groups.GroupsV1MigratedCache
|
||||
import org.thoughtcrime.securesms.groups.v2.ProfileKeySet
|
||||
import org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor
|
||||
import org.thoughtcrime.securesms.jobs.RequestGroupV2InfoJob
|
||||
@@ -574,8 +572,6 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
return existing.get()
|
||||
} else if (groupId.isV1 && groups.groupExists(groupId.requireV1().deriveV2MigrationGroupId())) {
|
||||
throw LegacyGroupInsertException(groupId)
|
||||
} else if (groupId.isV2 && GroupsV1MigratedCache.hasV1Group(groupId.requireV2())) {
|
||||
throw MissedGroupMigrationInsertException(groupId)
|
||||
} else {
|
||||
val values = ContentValues().apply {
|
||||
put(GROUP_ID, groupId.toString())
|
||||
@@ -589,8 +585,6 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
return existing.get()
|
||||
} else if (groupId.isV1 && groups.groupExists(groupId.requireV1().deriveV2MigrationGroupId())) {
|
||||
throw LegacyGroupInsertException(groupId)
|
||||
} else if (groupId.isV2 && groups.getGroupV1ByExpectedV2(groupId.requireV2()).isPresent) {
|
||||
throw MissedGroupMigrationInsertException(groupId)
|
||||
} else {
|
||||
throw AssertionError("Failed to insert recipient!")
|
||||
}
|
||||
@@ -644,14 +638,6 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
}
|
||||
|
||||
if (groupId.isV2) {
|
||||
val v1 = GroupsV1MigratedCache.getV1GroupByV2Id(groupId.requireV2())
|
||||
if (v1 != null) {
|
||||
db.setTransactionSuccessful()
|
||||
return v1.recipientId
|
||||
}
|
||||
}
|
||||
|
||||
val id = getOrInsertFromGroupId(groupId)
|
||||
db.setTransactionSuccessful()
|
||||
return id
|
||||
|
||||
@@ -5,9 +5,9 @@ import org.signal.libsignal.zkgroup.groups.GroupMasterKey
|
||||
import org.signal.storageservice.protos.groups.AccessControl
|
||||
import org.signal.storageservice.protos.groups.local.EnabledState
|
||||
import org.thoughtcrime.securesms.database.GroupTable
|
||||
import org.thoughtcrime.securesms.database.RecipientTable
|
||||
import org.thoughtcrime.securesms.groups.GroupAccessControl
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.groups.GroupsV1MigrationUtil
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
@@ -134,7 +134,7 @@ class GroupRecord(
|
||||
unmigratedV1Members
|
||||
.filterNot { members.contains(it) }
|
||||
.map { Recipient.resolved(it) }
|
||||
.filter { GroupsV1MigrationUtil.isAutoMigratable(it) }
|
||||
.filter { it.isAutoMigratable() }
|
||||
.map { it.id }
|
||||
}
|
||||
}
|
||||
@@ -181,4 +181,13 @@ class GroupRecord(
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* True if the user meets all the requirements to be auto-migrated, otherwise false.
|
||||
*/
|
||||
private fun Recipient.isAutoMigratable(): Boolean {
|
||||
return hasServiceId() && registered === RecipientTable.RegisteredState.REGISTERED && profileKey != null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user