Use CDN number instead of parsing identifier for attachment remote id.

This commit is contained in:
Cody Henthorne
2026-06-04 11:22:14 -04:00
committed by GitHub
parent af4d0a0ef0
commit f1a72dd01a
9 changed files with 18 additions and 15 deletions
@@ -31,7 +31,7 @@ fun Attachment.toAttachmentPointer(context: Context): AttachmentPointer? {
}
try {
val remoteId = SignalServiceAttachmentRemoteId.from(attachment.remoteLocation!!)
val remoteId = SignalServiceAttachmentRemoteId.from(attachment.remoteLocation!!, attachment.cdn.cdnNumber)
var attachmentWidth = attachment.width
var attachmentHeight = attachment.height
@@ -123,7 +123,7 @@ fun DatabaseAttachment.createArchiveAttachmentPointer(useArchiveCdn: Boolean): S
throw InvalidAttachmentException("empty content id")
}
SignalServiceAttachmentRemoteId.from(remoteLocation) to cdn.cdnNumber
SignalServiceAttachmentRemoteId.from(remoteLocation, cdn.cdnNumber) to cdn.cdnNumber
}
val key = Base64.decode(remoteKey)
@@ -87,7 +87,7 @@ fun FilePointer?.toLocalAttachment(
AttachmentType.TRANSIT -> {
val signalAttachmentPointer = SignalServiceAttachmentPointer(
cdnNumber = locatorInfo.transitCdnNumber ?: Cdn.CDN_0.cdnNumber,
remoteId = SignalServiceAttachmentRemoteId.from(locatorInfo.transitCdnKey!!),
remoteId = SignalServiceAttachmentRemoteId.from(locatorInfo.transitCdnKey!!, locatorInfo.transitCdnNumber ?: Cdn.CDN_0.cdnNumber),
contentType = contentType,
key = locatorInfo.key.toByteArray(),
size = Optional.ofNullable(locatorInfo.size),
@@ -399,8 +399,8 @@ class AttachmentDownloadJob private constructor(
}
return try {
val remoteId = SignalServiceAttachmentRemoteId.from(attachment.remoteLocation)
val cdnNumber = attachment.cdn.cdnNumber
val remoteId = SignalServiceAttachmentRemoteId.from(attachment.remoteLocation, cdnNumber)
val key = Base64.decode(attachment.remoteKey)
@@ -282,7 +282,7 @@ abstract class PushSendJob protected constructor(parameters: Parameters) : BaseJ
}
try {
val remoteId = SignalServiceAttachmentRemoteId.from(attachment.remoteLocation!!)
val remoteId = SignalServiceAttachmentRemoteId.from(attachment.remoteLocation!!, attachment.cdn.cdnNumber)
val key = Base64.decode(attachment.remoteKey!!)
var width = attachment.width
@@ -215,7 +215,7 @@ private fun Attachment.toAttachmentPointerProto(): Either<DataMessageError, Atta
raise(DataMessageError.MissingAttachmentRemoteFields)
}
val remoteIdResolved: SignalServiceAttachmentRemoteId = SignalServiceAttachmentRemoteId.from(remoteLocation)
val remoteIdResolved: SignalServiceAttachmentRemoteId = SignalServiceAttachmentRemoteId.from(remoteLocation, cdn.cdnNumber)
val keyBytes: ByteArray = try {
Base64.decode(remoteKey)