Allow 1:1 polls and raise character limit.

This commit is contained in:
Michelle Tang
2026-01-05 12:56:13 -05:00
committed by jeffrey-signal
parent fd635542c0
commit f7d87f3436
19 changed files with 138 additions and 156 deletions

View File

@@ -29,6 +29,7 @@ import org.whispersystems.signalservice.internal.util.Util
*/
object EnvelopeContentValidator {
private const val MAX_POLL_QUESTION_CHARACTER_LENGTH = 200
private const val MAX_POLL_CHARACTER_LENGTH = 100
private const val MIN_POLL_OPTIONS = 2
@@ -167,7 +168,7 @@ object EnvelopeContentValidator {
}
private fun DataMessage.PollCreate.hasInvalidPollQuestion(): Boolean {
return this.question.isNullOrBlank() || this.question.length > MAX_POLL_CHARACTER_LENGTH
return this.question.isNullOrBlank() || this.question.length > MAX_POLL_QUESTION_CHARACTER_LENGTH
}
private fun DataMessage.PollCreate.hasInvalidPollOptions(): Boolean {

View File

@@ -50,11 +50,11 @@ class EnvelopeContentValidatorTest {
}
@Test
fun `validate - ensure polls with a question exceeding 100 characters are marked invalid`() {
fun `validate - ensure polls with a question exceeding 200 characters are marked invalid`() {
val content = Content(
dataMessage = DataMessage(
pollCreate = DataMessage.PollCreate(
question = "abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyz",
question = "abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyz",
options = listOf("option1", "option2"),
allowMultiple = true
)