mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Ensure that audio attachments with text aren't exported as voice notes.
This commit is contained in:
@@ -1003,7 +1003,7 @@ private fun BackupMessageRecord.toRemoteStandardMessage(exportState: ExportState
|
|||||||
return StandardMessage(
|
return StandardMessage(
|
||||||
quote = this.toRemoteQuote(mediaArchiveEnabled, quotedAttachments),
|
quote = this.toRemoteQuote(mediaArchiveEnabled, quotedAttachments),
|
||||||
text = text.takeUnless { hasVoiceNote },
|
text = text.takeUnless { hasVoiceNote },
|
||||||
attachments = messageAttachments.toRemoteAttachments(mediaArchiveEnabled),
|
attachments = messageAttachments.toRemoteAttachments(mediaArchiveEnabled).withFixedVoiceNotes(textPresent = text != null || longTextAttachment != null),
|
||||||
linkPreview = linkPreviews.map { it.toRemoteLinkPreview(mediaArchiveEnabled) },
|
linkPreview = linkPreviews.map { it.toRemoteLinkPreview(mediaArchiveEnabled) },
|
||||||
longText = longTextAttachment?.toRemoteFilePointer(mediaArchiveEnabled),
|
longText = longTextAttachment?.toRemoteFilePointer(mediaArchiveEnabled),
|
||||||
reactions = reactionRecords.toRemote()
|
reactions = reactionRecords.toRemote()
|
||||||
@@ -1496,6 +1496,16 @@ private fun Text?.isNullOrBlank(): Boolean {
|
|||||||
return this == null || this.body.isBlank()
|
return this == null || this.body.isBlank()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun List<MessageAttachment>.withFixedVoiceNotes(textPresent: Boolean): List<MessageAttachment> {
|
||||||
|
return this.map {
|
||||||
|
if (textPresent && it.flag == MessageAttachment.Flag.VOICE_MESSAGE) {
|
||||||
|
it.copy(flag = MessageAttachment.Flag.NONE)
|
||||||
|
} else {
|
||||||
|
it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun Cursor.toBackupMessageRecord(pastIds: Set<Long>, backupStartTime: Long): BackupMessageRecord? {
|
private fun Cursor.toBackupMessageRecord(pastIds: Set<Long>, backupStartTime: Long): BackupMessageRecord? {
|
||||||
val id = this.requireLong(MessageTable.ID)
|
val id = this.requireLong(MessageTable.ID)
|
||||||
if (pastIds.contains(id)) {
|
if (pastIds.contains(id)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user