mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-20 17:57:29 +00:00
Fix unique constraint violation when importing groups with duplicate recipient IDs.
This commit is contained in:
committed by
Alex Hart
parent
4c9cdf3b8f
commit
44ea9ccc59
@@ -659,7 +659,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) :
|
||||
val membershipValues = mutableListOf<ContentValues>()
|
||||
val groupRecipientId = recipients.getOrInsertFromGroupId(groupId)
|
||||
val members: List<RecipientId> = memberCollection.toSet().sorted()
|
||||
var groupMembers: List<RecipientId> = members
|
||||
var groupMembers: Collection<RecipientId> = members
|
||||
|
||||
val values = ContentValues()
|
||||
|
||||
@@ -815,7 +815,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) :
|
||||
val groupMembers = getV2GroupMembers(decryptedGroup, true)
|
||||
var groupSendEndorsementRecords: GroupSendEndorsementRecords? = receivedGroupSendEndorsements?.toGroupSendEndorsementRecords() ?: getGroupSendEndorsements(groupId)
|
||||
|
||||
val addedMembers: List<RecipientId> = if (existingGroup.isPresent && existingGroup.get().isV2Group) {
|
||||
val addedMembers: Collection<RecipientId> = if (existingGroup.isPresent && existingGroup.get().isV2Group) {
|
||||
val change = GroupChangeReconstruct.reconstructGroupChange(existingGroup.get().requireV2GroupProperties().decryptedGroup, decryptedGroup)
|
||||
val removed: List<ServiceId> = DecryptedGroupUtil.removedMembersServiceIdList(change)
|
||||
|
||||
@@ -1420,7 +1420,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) :
|
||||
.toMutableList()
|
||||
}
|
||||
|
||||
private fun getV2GroupMembers(decryptedGroup: DecryptedGroup, shouldRetry: Boolean): List<RecipientId> {
|
||||
private fun getV2GroupMembers(decryptedGroup: DecryptedGroup, shouldRetry: Boolean): Set<RecipientId> {
|
||||
val ids: List<RecipientId> = decryptedGroup.members.toAciList().toRecipientIds()
|
||||
|
||||
return if (RemappedRecords.getInstance().areAnyRemapped(ids)) {
|
||||
@@ -1433,7 +1433,7 @@ class GroupTable(context: Context?, databaseHelper: SignalDatabase?) :
|
||||
throw IllegalStateException("Remapped records in group membership!")
|
||||
}
|
||||
} else {
|
||||
ids
|
||||
ids.toSet()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3877,7 +3877,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
}
|
||||
}
|
||||
|
||||
fun setHasGroupsInCommon(recipientIds: List<RecipientId?>) {
|
||||
fun setHasGroupsInCommon(recipientIds: Collection<RecipientId>) {
|
||||
if (recipientIds.isEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user