Migrate quotes to have a separate quoteTargetContentType.

This commit is contained in:
Greyson Parrelli
2025-08-29 15:39:51 -04:00
parent 631b51baf2
commit 662404d335
45 changed files with 435 additions and 132 deletions

View File

@@ -45,11 +45,13 @@ class ArchivedAttachment : Attachment {
stickerLocator: StickerLocator?,
gif: Boolean,
quote: Boolean,
quoteTargetContentType: String?,
uuid: UUID?,
fileName: String?
) : super(
contentType = contentType ?: "",
quote = quote,
quoteTargetContentType = quoteTargetContentType,
transferState = AttachmentTable.TRANSFER_NEEDS_RESTORE,
size = size,
fileName = fileName,

View File

@@ -59,6 +59,8 @@ abstract class Attachment(
@JvmField
val quote: Boolean,
@JvmField
val quoteTargetContentType: String?,
@JvmField
val uploadTimestamp: Long,
@JvmField
val caption: String?,
@@ -98,6 +100,7 @@ abstract class Attachment(
height = parcel.readInt(),
incrementalMacChunkSize = parcel.readInt(),
quote = ParcelUtil.readBoolean(parcel),
quoteTargetContentType = parcel.readString(),
uploadTimestamp = parcel.readLong(),
caption = parcel.readString(),
stickerLocator = ParcelCompat.readParcelable(parcel, StickerLocator::class.java.classLoader, StickerLocator::class.java),
@@ -126,6 +129,7 @@ abstract class Attachment(
dest.writeInt(height)
dest.writeInt(incrementalMacChunkSize)
ParcelUtil.writeBoolean(dest, quote)
dest.writeString(quoteTargetContentType)
dest.writeLong(uploadTimestamp)
dest.writeString(caption)
dest.writeParcelable(stickerLocator, 0)

View File

@@ -75,7 +75,8 @@ class DatabaseAttachment : Attachment {
archiveCdn: Int?,
thumbnailRestoreState: AttachmentTable.ThumbnailRestoreState,
archiveTransferState: AttachmentTable.ArchiveTransferState,
uuid: UUID?
uuid: UUID?,
quoteTargetContentType: String?
) : super(
contentType = contentType,
transferState = transferProgress,
@@ -93,6 +94,7 @@ class DatabaseAttachment : Attachment {
height = height,
incrementalMacChunkSize = incrementalMacChunkSize,
quote = quote,
quoteTargetContentType = quoteTargetContentType,
uploadTimestamp = uploadTimestamp,
caption = caption,
stickerLocator = stickerLocator,

View File

@@ -40,6 +40,7 @@ class LocalStickerAttachment : Attachment {
height = StickerSlide.HEIGHT,
incrementalMacChunkSize = 0,
quote = false,
quoteTargetContentType = null,
uploadTimestamp = 0,
caption = null,
stickerLocator = stickerLocator,

View File

@@ -38,7 +38,9 @@ class PointerAttachment : Attachment {
caption: String?,
stickerLocator: StickerLocator?,
blurHash: BlurHash?,
uuid: UUID?
uuid: UUID?,
quote: Boolean,
quoteTargetContentType: String? = null
) : super(
contentType = contentType,
transferState = transferState,
@@ -56,7 +58,8 @@ class PointerAttachment : Attachment {
width = width,
height = height,
incrementalMacChunkSize = incrementalMacChunkSize,
quote = false,
quote = quote,
quoteTargetContentType = quoteTargetContentType,
uploadTimestamp = uploadTimestamp,
caption = caption,
stickerLocator = stickerLocator,
@@ -91,7 +94,9 @@ class PointerAttachment : Attachment {
pointer: Optional<SignalServiceAttachment>,
stickerLocator: StickerLocator? = null,
fastPreflightId: String? = null,
transferState: Int = AttachmentTable.TRANSFER_PROGRESS_PENDING
transferState: Int = AttachmentTable.TRANSFER_PROGRESS_PENDING,
quote: Boolean = false,
quoteTargetContentType: String? = null
): Optional<Attachment> {
if (!pointer.isPresent || !pointer.get().isPointer()) {
return Optional.empty()
@@ -122,7 +127,9 @@ class PointerAttachment : Attachment {
caption = pointer.get().asPointer().caption.orElse(null),
stickerLocator = stickerLocator,
blurHash = BlurHash.parseOrNull(pointer.get().asPointer().blurHash.orElse(null)),
uuid = pointer.get().asPointer().uuid
uuid = pointer.get().asPointer().uuid,
quote = quote,
quoteTargetContentType = quoteTargetContentType
)
)
}
@@ -140,7 +147,9 @@ class PointerAttachment : Attachment {
return Optional.of(
PointerAttachment(
contentType = quotedAttachment.contentType!!,
quote = true,
contentType = quotedAttachment.thumbnail?.contentType,
quoteTargetContentType = quotedAttachment.contentType!!,
transferState = AttachmentTable.TRANSFER_PROGRESS_PENDING,
size = (if (thumbnail != null) thumbnail.asPointer().size.orElse(0) else 0).toLong(),
fileName = quotedAttachment.fileName,

View File

@@ -5,6 +5,7 @@ import android.os.Parcel
import org.thoughtcrime.securesms.blurhash.BlurHash
import org.thoughtcrime.securesms.database.AttachmentTable
import org.thoughtcrime.securesms.stickers.StickerLocator
import org.thoughtcrime.securesms.util.MediaUtil
import java.util.UUID
/**
@@ -14,9 +15,21 @@ import java.util.UUID
* quote them and know their contentType even though the media has been deleted.
*/
class TombstoneAttachment : Attachment {
constructor(contentType: String?, quote: Boolean) : super(
companion object {
fun forQuote(): TombstoneAttachment {
return TombstoneAttachment(contentType = null, quote = true, quoteTargetContentType = MediaUtil.VIEW_ONCE)
}
fun forNonQuote(contentType: String?): TombstoneAttachment {
return TombstoneAttachment(contentType = contentType, quote = false, quoteTargetContentType = null)
}
}
constructor(contentType: String?, quote: Boolean, quoteTargetContentType: String?) : super(
contentType = contentType,
quote = quote,
quoteTargetContentType = quoteTargetContentType,
transferState = AttachmentTable.TRANSFER_PROGRESS_DONE,
size = 0,
fileName = null,
@@ -55,10 +68,12 @@ class TombstoneAttachment : Attachment {
gif: Boolean = false,
stickerLocator: StickerLocator? = null,
quote: Boolean,
quoteTargetContentType: String?,
uuid: UUID?
) : super(
contentType = contentType ?: "",
quote = quote,
quoteTargetContentType = quoteTargetContentType,
transferState = AttachmentTable.TRANSFER_PROGRESS_PERMANENT_FAILURE,
size = 0,
fileName = fileName,

View File

@@ -22,6 +22,7 @@ class UriAttachment : Attachment {
borderless: Boolean,
videoGif: Boolean,
quote: Boolean,
quoteTargetContentType: String?,
caption: String?,
stickerLocator: StickerLocator?,
blurHash: BlurHash?,
@@ -40,6 +41,7 @@ class UriAttachment : Attachment {
borderless = borderless,
videoGif = videoGif,
quote = quote,
quoteTargetContentType = quoteTargetContentType,
caption = caption,
stickerLocator = stickerLocator,
blurHash = blurHash,
@@ -61,6 +63,7 @@ class UriAttachment : Attachment {
borderless: Boolean,
videoGif: Boolean,
quote: Boolean,
quoteTargetContentType: String?,
caption: String?,
stickerLocator: StickerLocator?,
blurHash: BlurHash?,
@@ -85,6 +88,7 @@ class UriAttachment : Attachment {
height = height,
incrementalMacChunkSize = 0,
quote = quote,
quoteTargetContentType = quoteTargetContentType,
uploadTimestamp = 0,
caption = caption,
stickerLocator = stickerLocator,

View File

@@ -30,6 +30,7 @@ class WallpaperAttachment() : Attachment(
height = 0,
incrementalMacChunkSize = 0,
quote = false,
quoteTargetContentType = null,
uploadTimestamp = 0,
caption = null,
stickerLocator = null,