Update sender key flag.

This commit is contained in:
Greyson Parrelli
2021-08-04 17:20:45 -04:00
committed by Alex Hart
parent 784c373a0e
commit 2b5b664a8f
5 changed files with 28 additions and 19 deletions

View File

@@ -150,7 +150,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
/** @return The ID of the inserted entry, or -1 if none was inserted. Can be used with [addRecipientToExistingEntryIfPossible] */
fun insertIfPossible(recipientId: RecipientId, sentTimestamp: Long, sendMessageResult: SendMessageResult, contentHint: ContentHint, messageId: MessageId): Long {
if (!FeatureFlags.senderKey()) return -1
if (!FeatureFlags.retryReceipts()) return -1
if (sendMessageResult.isSuccess && sendMessageResult.success.content.isPresent) {
val recipientDevice = listOf(RecipientDevice(recipientId, sendMessageResult.success.devices))
@@ -162,7 +162,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
/** @return The ID of the inserted entry, or -1 if none was inserted. Can be used with [addRecipientToExistingEntryIfPossible] */
fun insertIfPossible(recipientId: RecipientId, sentTimestamp: Long, sendMessageResult: SendMessageResult, contentHint: ContentHint, messageIds: List<MessageId>): Long {
if (!FeatureFlags.senderKey()) return -1
if (!FeatureFlags.retryReceipts()) return -1
if (sendMessageResult.isSuccess && sendMessageResult.success.content.isPresent) {
val recipientDevice = listOf(RecipientDevice(recipientId, sendMessageResult.success.devices))
@@ -174,7 +174,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
/** @return The ID of the inserted entry, or -1 if none was inserted. Can be used with [addRecipientToExistingEntryIfPossible] */
fun insertIfPossible(sentTimestamp: Long, possibleRecipients: List<Recipient>, results: List<SendMessageResult>, contentHint: ContentHint, messageId: MessageId): Long {
if (!FeatureFlags.senderKey()) return -1
if (!FeatureFlags.retryReceipts()) return -1
val accessList = RecipientAccessList(possibleRecipients)
@@ -195,7 +195,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
}
fun addRecipientToExistingEntryIfPossible(payloadId: Long, recipientId: RecipientId, sendMessageResult: SendMessageResult) {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
if (sendMessageResult.isSuccess && sendMessageResult.success.content.isPresent) {
val db = databaseHelper.writableDatabase
@@ -262,7 +262,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
}
fun getLogEntry(recipientId: RecipientId, device: Int, dateSent: Long): MessageLogEntry? {
if (!FeatureFlags.senderKey()) return null
if (!FeatureFlags.retryReceipts()) return null
trimOldMessages(System.currentTimeMillis(), FeatureFlags.retryRespondMaxAge())
@@ -302,7 +302,7 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
}
fun deleteAllRelatedToMessage(messageId: Long, mms: Boolean) {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
val db = databaseHelper.writableDatabase
val query = "${PayloadTable.ID} IN (SELECT ${MessageTable.PAYLOAD_ID} FROM ${MessageTable.TABLE_NAME} WHERE ${MessageTable.MESSAGE_ID} = ? AND ${MessageTable.IS_MMS} = ?)"
@@ -312,13 +312,13 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
}
fun deleteEntryForRecipient(dateSent: Long, recipientId: RecipientId, device: Int) {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
deleteEntriesForRecipient(listOf(dateSent), recipientId, device)
}
fun deleteEntriesForRecipient(dateSent: List<Long>, recipientId: RecipientId, device: Int) {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
val db = databaseHelper.writableDatabase
@@ -346,13 +346,13 @@ class MessageSendLogDatabase constructor(context: Context?, databaseHelper: SQLC
}
fun deleteAll() {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
databaseHelper.writableDatabase.delete(PayloadTable.TABLE_NAME, null, null)
}
fun trimOldMessages(currentTime: Long, maxAge: Long) {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
val db = databaseHelper.writableDatabase
val query = "${PayloadTable.DATE_SENT} < ?"

View File

@@ -23,7 +23,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
private var populated: Boolean = false
fun insert(author: RecipientId, authorDevice: Int, sentTimestamp: Long, receivedTimestamp: Long, threadId: Long) {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
ensurePopulated()
synchronized(pendingRetries) {
@@ -33,7 +33,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
}
fun get(author: RecipientId, sentTimestamp: Long): PendingRetryReceiptModel? {
if (!FeatureFlags.senderKey()) return null
if (!FeatureFlags.retryReceipts()) return null
ensurePopulated()
synchronized(pendingRetries) {
@@ -42,7 +42,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
}
fun getOldest(): PendingRetryReceiptModel? {
if (!FeatureFlags.senderKey()) return null
if (!FeatureFlags.retryReceipts()) return null
ensurePopulated()
synchronized(pendingRetries) {
@@ -51,7 +51,7 @@ class PendingRetryReceiptCache @VisibleForTesting constructor(
}
fun delete(model: PendingRetryReceiptModel) {
if (!FeatureFlags.senderKey()) return
if (!FeatureFlags.retryReceipts()) return
ensurePopulated()
synchronized(pendingRetries) {