mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-03-02 23:38:34 +00:00
Update inbound attachment processing.
This commit is contained in:
@@ -71,7 +71,7 @@ import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.isPaymentActiv
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.isPaymentActivationRequest
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.isStoryReaction
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointer
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointers
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointersWithinLimit
|
||||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage
|
||||
import org.thoughtcrime.securesms.mms.MmsException
|
||||
import org.thoughtcrime.securesms.mms.QuoteModel
|
||||
@@ -836,7 +836,7 @@ object DataMessageProcessor {
|
||||
val linkPreviews: List<LinkPreview> = getLinkPreviews(message.previewList, message.body ?: "", false)
|
||||
val mentions: List<Mention> = getMentions(message.bodyRangesList)
|
||||
val sticker: Attachment? = getStickerAttachment(envelope.timestamp, message)
|
||||
val attachments: List<Attachment> = message.attachmentsList.toPointers()
|
||||
val attachments: List<Attachment> = message.attachmentsList.toPointersWithinLimit()
|
||||
val messageRanges: BodyRangeList? = if (message.bodyRangesCount > 0) message.bodyRangesList.filter { it.hasStyle() }.toList().toBodyRangeList() else null
|
||||
|
||||
handlePossibleExpirationUpdate(envelope, metadata, senderRecipient.id, threadRecipient, groupId, message.expireTimer.seconds, receivedTime)
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.messages.MessageContentProcessorV2.Companion.l
|
||||
import org.thoughtcrime.securesms.messages.MessageContentProcessorV2.Companion.warn
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.groupId
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.isMediaMessage
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointers
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointersWithinLimit
|
||||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage
|
||||
import org.thoughtcrime.securesms.mms.QuoteModel
|
||||
import org.thoughtcrime.securesms.notifications.v2.ConversationId.Companion.forConversation
|
||||
@@ -136,7 +136,7 @@ object EditMessageProcessor {
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val attachments = message.attachmentsList.toPointers()
|
||||
val attachments = message.attachmentsList.toPointersWithinLimit()
|
||||
attachments.filter {
|
||||
MediaUtil.SlideType.LONG_TEXT == MediaUtil.getSlideTypeFromContentType(it.contentType)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.attachments.PointerAttachment
|
||||
import org.thoughtcrime.securesms.database.model.StoryType
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointer
|
||||
import org.thoughtcrime.securesms.stickers.StickerLocator
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.whispersystems.signalservice.api.InvalidMessageStructureException
|
||||
@@ -32,6 +31,8 @@ private val ByteString.isNotEmpty: Boolean
|
||||
|
||||
object SignalServiceProtoUtil {
|
||||
|
||||
const val MAX_ALLOWED_ATTACHMENTS = 100
|
||||
|
||||
/** Contains some user data that affects the conversation */
|
||||
val DataMessage.hasRenderableContent: Boolean
|
||||
get() {
|
||||
@@ -159,8 +160,8 @@ object SignalServiceProtoUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun List<AttachmentPointer>.toPointers(): List<Attachment> {
|
||||
return mapNotNull { it.toPointer() }
|
||||
fun List<AttachmentPointer>.toPointersWithinLimit(): List<Attachment> {
|
||||
return mapNotNull { it.toPointer() }.take(MAX_ALLOWED_ATTACHMENTS)
|
||||
}
|
||||
|
||||
fun AttachmentPointer.toPointer(stickerLocator: StickerLocator? = null): Attachment? {
|
||||
|
||||
@@ -65,7 +65,7 @@ import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.isUnidentified
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.serviceIdsToUnidentifiedStatus
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toMobileCoinMoney
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointer
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointers
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toPointersWithinLimit
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toSignalServiceAttachmentPointer
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.type
|
||||
import org.thoughtcrime.securesms.mms.MmsException
|
||||
@@ -342,7 +342,7 @@ object SyncMessageProcessor {
|
||||
val viewOnce: Boolean = message.isViewOnce
|
||||
val bodyRanges: BodyRangeList? = message.bodyRangesList.toBodyRangeList()
|
||||
|
||||
val syncAttachments = message.attachmentsList.toPointers().filter {
|
||||
val syncAttachments = message.attachmentsList.toPointersWithinLimit().filter {
|
||||
MediaUtil.SlideType.LONG_TEXT == MediaUtil.getSlideTypeFromContentType(it.contentType)
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ object SyncMessageProcessor {
|
||||
val giftBadge: GiftBadge? = if (sent.message.hasGiftBadge()) GiftBadge.newBuilder().setRedemptionToken(sent.message.giftBadge.receiptCredentialPresentation).build() else null
|
||||
val viewOnce: Boolean = sent.message.isViewOnce
|
||||
val bodyRanges: BodyRangeList? = sent.message.bodyRangesList.toBodyRangeList()
|
||||
val syncAttachments: List<Attachment> = listOfNotNull(sticker) + if (viewOnce) listOf<Attachment>(TombstoneAttachment(MediaUtil.VIEW_ONCE, false)) else sent.message.attachmentsList.toPointers()
|
||||
val syncAttachments: List<Attachment> = listOfNotNull(sticker) + if (viewOnce) listOf<Attachment>(TombstoneAttachment(MediaUtil.VIEW_ONCE, false)) else sent.message.attachmentsList.toPointersWithinLimit()
|
||||
|
||||
val mediaMessage = OutgoingMessage(
|
||||
recipient = recipient,
|
||||
|
||||
Reference in New Issue
Block a user