Add various backup fixes for polls.

This commit is contained in:
Michelle Tang
2025-10-29 09:54:40 -04:00
committed by jeffrey-signal
parent 3f5a4ebf7b
commit 47201f4955
39 changed files with 45 additions and 7 deletions

View File

@@ -120,6 +120,8 @@ import kotlin.time.Duration.Companion.seconds
object DataMessageProcessor {
private const val BODY_RANGE_PROCESSING_LIMIT = 250
private const val POLL_CHARACTER_LIMIT = 100
private const val POLL_OPTIONS_LIMIT = 10
fun process(
context: Context,
@@ -1079,6 +1081,16 @@ object DataMessageProcessor {
return null
}
if (poll.question == null || poll.question!!.isEmpty() || poll.question!!.length > POLL_CHARACTER_LIMIT) {
warn(envelope.timestamp!!, "[handlePollCreate] Poll question is invalid.")
return null
}
if (poll.options.isEmpty() || poll.options.size > POLL_OPTIONS_LIMIT || poll.options.any { it.isEmpty() || it.length > POLL_CHARACTER_LIMIT }) {
warn(envelope.timestamp!!, "[handlePollCreate] Poll option is invalid.")
return null
}
val pollMessage = IncomingMessage(
type = MessageType.NORMAL,
from = senderRecipient.id,