Clear incrementalMac if we discover it's bad during playback.

This commit is contained in:
Greyson Parrelli
2025-08-25 12:35:17 -04:00
committed by Michelle Tang
parent 45c64f825d
commit 2046b44fce
9 changed files with 124 additions and 24 deletions

View File

@@ -966,6 +966,26 @@ class AttachmentTable(
}
}
/**
* Clears out the incrementalMac for the specified [attachmentId], as well as any other attachments that share the same ([remoteKey], [plaintextHash]) pair (if present).
*/
fun clearIncrementalMacsForAttachmentAndAnyDuplicates(attachmentId: AttachmentId, remoteKey: String?, plaintextHash: String?) {
val query = if (remoteKey != null && plaintextHash != null) {
SqlUtil.buildQuery("$ID = ? OR ($REMOTE_KEY = ? AND $DATA_HASH_END = ?)", attachmentId, remoteKey, plaintextHash)
} else {
SqlUtil.buildQuery("$ID = ?", attachmentId)
}
writableDatabase
.update(TABLE_NAME)
.values(
REMOTE_INCREMENTAL_DIGEST to null,
REMOTE_INCREMENTAL_DIGEST_CHUNK_SIZE to 0
)
.where(query.where, query.whereArgs)
.run()
}
fun deleteAttachmentsForMessage(mmsId: Long): Boolean {
Log.d(TAG, "[deleteAttachmentsForMessage] mmsId: $mmsId")