Limit body ranges processed on received messages.

This commit is contained in:
Cody Henthorne
2023-05-18 13:02:17 -04:00
committed by Greyson Parrelli
parent a7e5ab1a6a
commit 866408f673
2 changed files with 12 additions and 2 deletions

View File

@@ -110,6 +110,8 @@ import kotlin.time.Duration.Companion.seconds
object DataMessageProcessor {
private const val BODY_RANGE_PROCESSING_LIMIT = 250
fun process(
context: Context,
senderRecipient: Recipient,
@@ -834,10 +836,10 @@ object DataMessageProcessor {
val quote: QuoteModel? = getValidatedQuote(context, envelope.timestamp, message)
val contacts: List<Contact> = getContacts(message)
val linkPreviews: List<LinkPreview> = getLinkPreviews(message.previewList, message.body ?: "", false)
val mentions: List<Mention> = getMentions(message.bodyRangesList)
val mentions: List<Mention> = getMentions(message.bodyRangesList.take(BODY_RANGE_PROCESSING_LIMIT))
val sticker: Attachment? = getStickerAttachment(envelope.timestamp, message)
val attachments: List<Attachment> = message.attachmentsList.toPointersWithinLimit()
val messageRanges: BodyRangeList? = if (message.bodyRangesCount > 0) message.bodyRangesList.filter { it.hasStyle() }.toList().toBodyRangeList() else null
val messageRanges: BodyRangeList? = if (message.bodyRangesCount > 0) message.bodyRangesList.asSequence().take(BODY_RANGE_PROCESSING_LIMIT).filter { it.hasStyle() }.toList().toBodyRangeList() else null
handlePossibleExpirationUpdate(envelope, metadata, senderRecipient.id, threadRecipient, groupId, message.expireTimer.seconds, receivedTime)