Update types of messages we backup.

This commit is contained in:
Greyson Parrelli
2024-01-11 10:26:05 -05:00
committed by GitHub
parent d7b79314d9
commit 4216b56443
2 changed files with 26 additions and 37 deletions

View File

@@ -2245,6 +2245,13 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
* Trims data related to expired messages. Only intended to be run after a backup restore.
*/
fun trimEntriesForExpiredMessages() {
val messageDeleteCount = writableDatabase
.delete(TABLE_NAME)
.where("$EXPIRE_STARTED > 0 AND $EXPIRES_IN > 0 AND ($EXPIRE_STARTED + $EXPIRES_IN) < ${System.currentTimeMillis()}")
.run()
Log.d(TAG, "Deleted $messageDeleteCount expired messages after backup.")
writableDatabase
.delete(GroupReceiptTable.TABLE_NAME)
.where("${GroupReceiptTable.MMS_ID} NOT IN (SELECT $ID FROM $TABLE_NAME)")
@@ -2273,23 +2280,6 @@ open class MessageTable(context: Context?, databaseHelper: SignalDatabase) : Dat
}
}
fun getNotification(messageId: Long): Optional<MmsNotificationInfo> {
return readableDatabase
.select(FROM_RECIPIENT_ID, MMS_CONTENT_LOCATION, MMS_TRANSACTION_ID, SMS_SUBSCRIPTION_ID)
.from(TABLE_NAME)
.where("$ID = ?", messageId)
.run()
.readToSingleObject { cursor ->
MmsNotificationInfo(
from = RecipientId.from(cursor.requireLong(FROM_RECIPIENT_ID)),
contentLocation = cursor.requireNonNullString(MMS_CONTENT_LOCATION),
transactionId = cursor.requireNonNullString(MMS_TRANSACTION_ID),
subscriptionId = cursor.requireInt(SMS_SUBSCRIPTION_ID)
)
}
.toOptional()
}
@Throws(MmsException::class, NoSuchMessageException::class)
fun getOutgoingMessage(messageId: Long): OutgoingMessage {
return rawQueryWithAttachments(RAW_ID_WHERE, arrayOf(messageId.toString())).readToSingleObject { cursor ->