Update plaintext export rules.
This commit is contained in:
parent
ab4a38d565
commit
48901f64c7
@ -2558,6 +2558,9 @@ enum class BackupMode {
|
||||
|
||||
val isLocalBackup: Boolean
|
||||
get() = this == LOCAL
|
||||
|
||||
val isPlaintextExport: Boolean
|
||||
get() = this == PLAINTEXT_EXPORT
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -167,7 +167,11 @@ fun MessageTable.getMessagesForBackup(db: SignalDatabase, backupTime: Long, self
|
||||
.where(
|
||||
buildString {
|
||||
append("$STORY_TYPE = 0 AND $PARENT_STORY_ID <= 0 AND $SCHEDULED_DATE = -1 AND ")
|
||||
append("($EXPIRES_IN == 0 OR $EXPIRES_IN > ${1.days.inWholeMilliseconds})")
|
||||
if (exportState.backupMode.isPlaintextExport) {
|
||||
append("$EXPIRES_IN == 0")
|
||||
} else {
|
||||
append("($EXPIRES_IN == 0 OR $EXPIRES_IN > ${1.days.inWholeMilliseconds})")
|
||||
}
|
||||
append(" AND $DATE_RECEIVED >= $lastSeenReceivedTime $cutoffQuery")
|
||||
}
|
||||
)
|
||||
|
||||
@ -647,15 +647,22 @@ private fun BackupMessageRecord.toBasicChatItemBuilder(selfRecipientId: Recipien
|
||||
}
|
||||
}
|
||||
|
||||
if (!MessageTypes.isExpirationTimerUpdate(record.type) && builder.expiresInMs != null && builder.expireStartDate != null) {
|
||||
val cutoffDuration = ChatItemArchiveExporter.EXPIRATION_CUTOFF.inWholeMilliseconds
|
||||
val expiresAt = builder.expireStartDate!! + builder.expiresInMs!!
|
||||
val threshold = if (exportState.backupMode.isLinkAndSync) backupStartTime else backupStartTime + cutoffDuration
|
||||
|
||||
if (expiresAt < threshold || (builder.expiresInMs!! <= cutoffDuration && !exportState.backupMode.isLinkAndSync)) {
|
||||
if (!MessageTypes.isExpirationTimerUpdate(record.type) && builder.expiresInMs != null) {
|
||||
if (exportState.backupMode.isPlaintextExport) {
|
||||
Log.w(TAG, ExportSkips.messageExpiresTooSoon(record.dateSent))
|
||||
return null
|
||||
}
|
||||
|
||||
if (builder.expireStartDate != null) {
|
||||
val cutoffDuration = ChatItemArchiveExporter.EXPIRATION_CUTOFF.inWholeMilliseconds
|
||||
val expiresAt = builder.expireStartDate!! + builder.expiresInMs!!
|
||||
val threshold = if (exportState.backupMode.isLinkAndSync) backupStartTime else backupStartTime + cutoffDuration
|
||||
|
||||
if (expiresAt < threshold || (builder.expiresInMs!! <= cutoffDuration && !exportState.backupMode.isLinkAndSync)) {
|
||||
Log.w(TAG, ExportSkips.messageExpiresTooSoon(record.dateSent))
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (builder.expireStartDate != null && builder.expiresInMs == null) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user