mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Upgrade ktlint and add twitter compose rules.
This commit is contained in:
committed by
Greyson Parrelli
parent
52e9b31554
commit
605289aca4
@@ -50,7 +50,8 @@ class DistributionListTables constructor(context: Context?, databaseHelper: Sign
|
||||
|
||||
fun insertInitialDistributionListAtCreationTime(db: net.zetetic.database.sqlcipher.SQLiteDatabase) {
|
||||
val recipientId = db.insert(
|
||||
RecipientTable.TABLE_NAME, null,
|
||||
RecipientTable.TABLE_NAME,
|
||||
null,
|
||||
contentValuesOf(
|
||||
RecipientTable.GROUP_TYPE to RecipientTable.GroupType.DISTRIBUTION_LIST.id,
|
||||
RecipientTable.DISTRIBUTION_LIST_ID to DistributionListId.MY_STORY_ID,
|
||||
@@ -59,7 +60,8 @@ class DistributionListTables constructor(context: Context?, databaseHelper: Sign
|
||||
)
|
||||
)
|
||||
db.insert(
|
||||
ListTable.TABLE_NAME, null,
|
||||
ListTable.TABLE_NAME,
|
||||
null,
|
||||
contentValuesOf(
|
||||
ListTable.ID to DistributionListId.MY_STORY_ID,
|
||||
ListTable.NAME to DistributionId.MY_STORY.toString(),
|
||||
@@ -549,7 +551,9 @@ class DistributionListTables constructor(context: Context?, databaseHelper: Sign
|
||||
arrayOf(ListTable.RECIPIENT_ID),
|
||||
"${ListTable.DISTRIBUTION_ID} = ?",
|
||||
SqlUtil.buildArgs(distributionId.toString()),
|
||||
null, null, null
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)?.use { cursor ->
|
||||
if (cursor.moveToFirst()) {
|
||||
RecipientId.from(CursorUtil.requireLong(cursor, ListTable.RECIPIENT_ID))
|
||||
@@ -565,7 +569,9 @@ class DistributionListTables constructor(context: Context?, databaseHelper: Sign
|
||||
arrayOf(ListTable.RECIPIENT_ID),
|
||||
"${ListTable.ID} = ?",
|
||||
SqlUtil.buildArgs(distributionListId),
|
||||
null, null, null
|
||||
null,
|
||||
null,
|
||||
null
|
||||
)?.use { cursor ->
|
||||
if (cursor.moveToFirst()) {
|
||||
RecipientId.from(CursorUtil.requireLong(cursor, ListTable.RECIPIENT_ID))
|
||||
|
||||
@@ -129,7 +129,8 @@ class LocalMetricsDatabase private constructor(
|
||||
try {
|
||||
event.splits.forEach { split ->
|
||||
db.insert(
|
||||
TABLE_NAME, null,
|
||||
TABLE_NAME,
|
||||
null,
|
||||
ContentValues().apply {
|
||||
put(CREATED_AT, event.createdAt)
|
||||
put(EVENT_ID, event.eventId)
|
||||
|
||||
@@ -83,7 +83,7 @@ class MessageSendLogTables constructor(context: Context?, databaseHelper: Signal
|
||||
|
||||
/** Created for [deleteEntriesForRecipient] */
|
||||
val CREATE_INDEXES = arrayOf(
|
||||
"CREATE INDEX msl_payload_date_sent_index ON $TABLE_NAME ($DATE_SENT)",
|
||||
"CREATE INDEX msl_payload_date_sent_index ON $TABLE_NAME ($DATE_SENT)"
|
||||
)
|
||||
|
||||
val CREATE_TRIGGERS = arrayOf(
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
@file:Suppress("ktlint:filename")
|
||||
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.content.ContentValues
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import net.zetetic.database.sqlcipher.SQLiteConstraintException
|
||||
import android.database.sqlite.SQLiteConstraintException
|
||||
import org.signal.core.util.SqlUtil
|
||||
import org.signal.core.util.requireBoolean
|
||||
import org.signal.core.util.requireInt
|
||||
|
||||
@@ -33,6 +33,7 @@ data class PnpDataSet(
|
||||
this.removeIf { it.id == toUpdate.id }
|
||||
this += update(toUpdate)
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the set of operations and returns the resulting dataset.
|
||||
* Important: This only occurs _in memory_. You must still apply the operations to disk to persist them.
|
||||
|
||||
@@ -784,7 +784,9 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
|
||||
return if (result.isNotEmpty()) {
|
||||
result[0]
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun markNeedsSyncWithoutRefresh(recipientIds: Collection<RecipientId>) {
|
||||
@@ -2574,7 +2576,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
val fullData = partialData.copy(
|
||||
e164Record = partialData.byE164?.let { getRecord(it) },
|
||||
pniSidRecord = partialData.byPniSid?.let { getRecord(it) },
|
||||
aciSidRecord = partialData.byAciSid?.let { getRecord(it) },
|
||||
aciSidRecord = partialData.byAciSid?.let { getRecord(it) }
|
||||
)
|
||||
|
||||
check(fullData.commonId == null)
|
||||
@@ -4032,7 +4034,7 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
storiesCapability = Recipient.Capability.deserialize(Bitmask.read(capabilities, Capabilities.STORIES, Capabilities.BIT_LENGTH).toInt()),
|
||||
giftBadgesCapability = Recipient.Capability.deserialize(Bitmask.read(capabilities, Capabilities.GIFT_BADGES, Capabilities.BIT_LENGTH).toInt()),
|
||||
pnpCapability = Recipient.Capability.deserialize(Bitmask.read(capabilities, Capabilities.PNP, Capabilities.BIT_LENGTH).toInt()),
|
||||
paymentActivation = Recipient.Capability.deserialize(Bitmask.read(capabilities, Capabilities.PAYMENT_ACTIVATION, Capabilities.BIT_LENGTH).toInt()),
|
||||
paymentActivation = Recipient.Capability.deserialize(Bitmask.read(capabilities, Capabilities.PAYMENT_ACTIVATION, Capabilities.BIT_LENGTH).toInt())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4551,6 +4553,6 @@ open class RecipientTable(context: Context, databaseHelper: SignalDatabase) : Da
|
||||
val oldIds: Set<RecipientId>,
|
||||
val changedNumberId: RecipientId?,
|
||||
val operations: List<PnpOperation>,
|
||||
val breadCrumbs: List<String>,
|
||||
val breadCrumbs: List<String>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class SearchTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
|
||||
@Language("sql")
|
||||
val CREATE_TABLE = arrayOf(
|
||||
"CREATE VIRTUAL TABLE $FTS_TABLE_NAME USING fts5($BODY, $THREAD_ID UNINDEXED, content=${MessageTable.TABLE_NAME}, content_rowid=${MessageTable.ID})",
|
||||
"CREATE VIRTUAL TABLE $FTS_TABLE_NAME USING fts5($BODY, $THREAD_ID UNINDEXED, content=${MessageTable.TABLE_NAME}, content_rowid=${MessageTable.ID})"
|
||||
)
|
||||
|
||||
@Language("sql")
|
||||
|
||||
@@ -50,7 +50,7 @@ class SenderKeySharedTable internal constructor(context: Context?, databaseHelpe
|
||||
ADDRESS to address.name,
|
||||
DEVICE to address.deviceId,
|
||||
DISTRIBUTION_ID to distributionId.toString(),
|
||||
TIMESTAMP to System.currentTimeMillis(),
|
||||
TIMESTAMP to System.currentTimeMillis()
|
||||
)
|
||||
db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE)
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class SenderKeyTable internal constructor(context: Context?, databaseHelper: Sig
|
||||
DEVICE to address.deviceId,
|
||||
DISTRIBUTION_ID to distributionId.toString(),
|
||||
RECORD to record.serialize(),
|
||||
CREATED_AT to System.currentTimeMillis(),
|
||||
CREATED_AT to System.currentTimeMillis()
|
||||
)
|
||||
db.insertWithOnConflict(TABLE_NAME, null, insertValues, SQLiteDatabase.CONFLICT_REPLACE)
|
||||
}
|
||||
|
||||
@@ -59,7 +59,10 @@ class SqlCipherErrorHandler(private val databaseName: String) : DatabaseErrorHan
|
||||
|
||||
try {
|
||||
SQLiteDatabase.openOrCreateDatabase(
|
||||
databaseFile.absolutePath, DatabaseSecretProvider.getOrCreateDatabaseSecret(context).asString(), null, null,
|
||||
databaseFile.absolutePath,
|
||||
DatabaseSecretProvider.getOrCreateDatabaseSecret(context).asString(),
|
||||
null,
|
||||
null,
|
||||
object : SQLiteDatabaseHook {
|
||||
override fun preKey(connection: SQLiteConnection) {}
|
||||
override fun postKey(connection: SQLiteConnection) {
|
||||
|
||||
@@ -46,7 +46,7 @@ class StorySendTable(context: Context, databaseHelper: SignalDatabase) : Databas
|
||||
|
||||
val CREATE_INDEXS = arrayOf(
|
||||
"CREATE INDEX story_sends_recipient_id_sent_timestamp_allows_replies_index ON $TABLE_NAME ($RECIPIENT_ID, $SENT_TIMESTAMP, $ALLOWS_REPLIES)",
|
||||
"CREATE INDEX story_sends_message_id_distribution_id_index ON $TABLE_NAME ($MESSAGE_ID, $DISTRIBUTION_ID)",
|
||||
"CREATE INDEX story_sends_message_id_distribution_id_index ON $TABLE_NAME ($MESSAGE_ID, $DISTRIBUTION_ID)"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1766,11 +1766,13 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
private fun getSnippetUri(cursor: Cursor?): Uri? {
|
||||
return if (cursor!!.isNull(cursor.getColumnIndexOrThrow(SNIPPET_URI))) {
|
||||
null
|
||||
} else try {
|
||||
Uri.parse(cursor.getString(cursor.getColumnIndexOrThrow(SNIPPET_URI)))
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.w(TAG, e)
|
||||
null
|
||||
} else {
|
||||
try {
|
||||
Uri.parse(cursor.getString(cursor.getColumnIndexOrThrow(SNIPPET_URI)))
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Log.w(TAG, e)
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1780,17 +1782,39 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
}
|
||||
|
||||
data class Extra(
|
||||
@field:JsonProperty @param:JsonProperty("isRevealable") val isViewOnce: Boolean = false,
|
||||
@field:JsonProperty @param:JsonProperty("isSticker") val isSticker: Boolean = false,
|
||||
@field:JsonProperty @param:JsonProperty("stickerEmoji") val stickerEmoji: String? = null,
|
||||
@field:JsonProperty @param:JsonProperty("isAlbum") val isAlbum: Boolean = false,
|
||||
@field:JsonProperty @param:JsonProperty("isRemoteDelete") val isRemoteDelete: Boolean = false,
|
||||
@field:JsonProperty @param:JsonProperty("isMessageRequestAccepted") val isMessageRequestAccepted: Boolean = true,
|
||||
@field:JsonProperty @param:JsonProperty("isGv2Invite") val isGv2Invite: Boolean = false,
|
||||
@field:JsonProperty @param:JsonProperty("groupAddedBy") val groupAddedBy: String? = null,
|
||||
@field:JsonProperty @param:JsonProperty("individualRecipientId") private val individualRecipientId: String,
|
||||
@field:JsonProperty @param:JsonProperty("bodyRanges") val bodyRanges: String? = null,
|
||||
@field:JsonProperty @param:JsonProperty("isScheduled") val isScheduled: Boolean = false
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isRevealable")
|
||||
val isViewOnce: Boolean = false,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isSticker")
|
||||
val isSticker: Boolean = false,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("stickerEmoji")
|
||||
val stickerEmoji: String? = null,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isAlbum")
|
||||
val isAlbum: Boolean = false,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isRemoteDelete")
|
||||
val isRemoteDelete: Boolean = false,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isMessageRequestAccepted")
|
||||
val isMessageRequestAccepted: Boolean = true,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isGv2Invite")
|
||||
val isGv2Invite: Boolean = false,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("groupAddedBy")
|
||||
val groupAddedBy: String? = null,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("individualRecipientId")
|
||||
private val individualRecipientId: String,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("bodyRanges")
|
||||
val bodyRanges: String? = null,
|
||||
@field:JsonProperty
|
||||
@param:JsonProperty("isScheduled")
|
||||
val isScheduled: Boolean = false
|
||||
) {
|
||||
|
||||
fun getIndividualRecipientId(): String {
|
||||
|
||||
@@ -2441,7 +2441,8 @@ object V149_LegacyMigrations : SignalDatabaseMigration {
|
||||
)
|
||||
|
||||
val recipientId = db.insert(
|
||||
"recipient", null,
|
||||
"recipient",
|
||||
null,
|
||||
contentValuesOf(
|
||||
"distribution_list_id" to 1L,
|
||||
"storage_service_key" to Base64.encodeBytes(StorageSyncHelper.generateKey()),
|
||||
@@ -2451,7 +2452,8 @@ object V149_LegacyMigrations : SignalDatabaseMigration {
|
||||
|
||||
val listUUID = UUID.randomUUID().toString()
|
||||
db.insert(
|
||||
"distribution_list", null,
|
||||
"distribution_list",
|
||||
null,
|
||||
contentValuesOf(
|
||||
"_id" to 1L,
|
||||
"name" to listUUID,
|
||||
|
||||
Reference in New Issue
Block a user