mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 09:49:30 +01:00
Implement new Safety Number Changes bottom sheeet.
This commit is contained in:
@@ -488,6 +488,13 @@ class DistributionListDatabase constructor(context: Context?, databaseHelper: Si
|
||||
.run()
|
||||
}
|
||||
|
||||
fun removeAllMembers(listId: DistributionListId, privacyMode: DistributionListPrivacyMode) {
|
||||
writableDatabase
|
||||
.delete(MembershipTable.TABLE_NAME)
|
||||
.where("${MembershipTable.LIST_ID} = ? AND ${MembershipTable.PRIVACY_MODE} = ?", listId.serialize(), privacyMode.serialize())
|
||||
.run()
|
||||
}
|
||||
|
||||
fun remapRecipient(oldId: RecipientId, newId: RecipientId) {
|
||||
val values = ContentValues().apply {
|
||||
put(MembershipTable.RECIPIENT_ID, newId.serialize())
|
||||
@@ -644,4 +651,33 @@ class DistributionListDatabase constructor(context: Context?, databaseHelper: Si
|
||||
private fun createUniqueNameForUnknownDistributionId(): String {
|
||||
return "DELETED-${UUID.randomUUID()}"
|
||||
}
|
||||
|
||||
fun excludeFromStory(recipientId: RecipientId, record: DistributionListRecord) {
|
||||
excludeAllFromStory(listOf(recipientId), record)
|
||||
}
|
||||
|
||||
fun excludeAllFromStory(recipientIds: List<RecipientId>, record: DistributionListRecord) {
|
||||
writableDatabase.withinTransaction {
|
||||
when (record.privacyMode) {
|
||||
DistributionListPrivacyMode.ONLY_WITH -> {
|
||||
recipientIds.forEach {
|
||||
removeMemberFromList(record.id, record.privacyMode, it)
|
||||
}
|
||||
}
|
||||
DistributionListPrivacyMode.ALL_EXCEPT -> {
|
||||
recipientIds.forEach {
|
||||
addMemberToList(record.id, record.privacyMode, it)
|
||||
}
|
||||
}
|
||||
DistributionListPrivacyMode.ALL -> {
|
||||
removeAllMembers(record.id, DistributionListPrivacyMode.ALL_EXCEPT)
|
||||
setPrivacyMode(record.id, DistributionListPrivacyMode.ALL_EXCEPT)
|
||||
|
||||
recipientIds.forEach {
|
||||
addMemberToList(record.id, DistributionListPrivacyMode.ALL_EXCEPT, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package org.thoughtcrime.securesms.database.model
|
||||
|
||||
import android.os.Parcelable
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
/**
|
||||
* Represents a pair of values that can be used to find a message. Because we have two tables,
|
||||
* that means this has both the primary key and a boolean indicating which table it's in.
|
||||
*/
|
||||
@Parcelize
|
||||
data class MessageId(
|
||||
val id: Long,
|
||||
@get:JvmName("isMms") val mms: Boolean
|
||||
) {
|
||||
) : Parcelable {
|
||||
fun serialize(): String {
|
||||
return "$id|$mms"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user