mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 16:49:40 +01:00
Introduce extra caching for group message processing.
This commit is contained in:
@@ -44,6 +44,7 @@ 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
|
||||
@@ -669,7 +670,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
|
||||
fun create(groupMasterKey: GroupMasterKey, groupState: DecryptedGroup, force: Boolean = false): GroupId.V2? {
|
||||
val groupId = GroupId.v2(groupMasterKey)
|
||||
|
||||
if (!force && getGroupV1ByExpectedV2(groupId).isPresent) {
|
||||
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!")
|
||||
@@ -688,7 +689,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) : DatabaseT
|
||||
*/
|
||||
fun fixMissingMasterKey(groupMasterKey: GroupMasterKey) {
|
||||
val groupId = GroupId.v2(groupMasterKey)
|
||||
if (getGroupV1ByExpectedV2(groupId).isPresent) {
|
||||
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.")
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ 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
|
||||
@@ -576,7 +577,7 @@ 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) {
|
||||
} else if (groupId.isV2 && GroupsV1MigratedCache.hasV1Group(groupId.requireV2())) {
|
||||
throw MissedGroupMigrationInsertException(groupId)
|
||||
} else {
|
||||
val values = ContentValues().apply {
|
||||
@@ -641,10 +642,10 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
|
||||
if (groupId.isV2) {
|
||||
val v1 = groups.getGroupV1ByExpectedV2(groupId.requireV2())
|
||||
if (v1.isPresent) {
|
||||
val v1 = GroupsV1MigratedCache.getV1GroupByV2Id(groupId.requireV2())
|
||||
if (v1 != null) {
|
||||
db.setTransactionSuccessful()
|
||||
return v1.get().recipientId
|
||||
return v1.recipientId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user