mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 02:58:45 +00:00
Put poll receive support behind feature flag.
This commit is contained in:
@@ -4,6 +4,8 @@ import androidx.test.core.app.ApplicationProvider
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.isEqualTo
|
||||
import io.mockk.every
|
||||
import io.mockk.mockkStatic
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -20,6 +22,7 @@ import org.thoughtcrime.securesms.testing.GroupTestingUtils
|
||||
import org.thoughtcrime.securesms.testing.GroupTestingUtils.asMember
|
||||
import org.thoughtcrime.securesms.testing.MessageContentFuzzer
|
||||
import org.thoughtcrime.securesms.testing.SignalActivityRule
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.whispersystems.signalservice.api.crypto.EnvelopeMetadata
|
||||
import org.whispersystems.signalservice.internal.push.DataMessage
|
||||
|
||||
@@ -38,6 +41,10 @@ class DataMessageProcessorTest_polls {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockkStatic(RemoteConfig::class)
|
||||
|
||||
every { RemoteConfig.receivePolls } returns true
|
||||
|
||||
alice = Recipient.resolved(harness.others[0])
|
||||
bob = Recipient.resolved(harness.others[1])
|
||||
charlie = Recipient.resolved(harness.others[2])
|
||||
|
||||
@@ -1056,6 +1056,11 @@ object DataMessageProcessor {
|
||||
groupId: GroupId.V2?,
|
||||
receivedTime: Long
|
||||
): InsertResult? {
|
||||
if (!RemoteConfig.receivePolls) {
|
||||
log(envelope.timestamp!!, "Poll creation not allowed due to remote config.")
|
||||
return null
|
||||
}
|
||||
|
||||
log(envelope.timestamp!!, "Handle poll creation")
|
||||
val poll: DataMessage.PollCreate = message.pollCreate!!
|
||||
|
||||
@@ -1111,6 +1116,11 @@ object DataMessageProcessor {
|
||||
groupId: GroupId.V2?,
|
||||
receivedTime: Long
|
||||
): InsertResult? {
|
||||
if (!RemoteConfig.receivePolls) {
|
||||
log(envelope.timestamp!!, "Poll terminate not allowed due to remote config.")
|
||||
return null
|
||||
}
|
||||
|
||||
val pollTerminate: DataMessage.PollTerminate = message.pollTerminate!!
|
||||
val targetSentTimestamp = pollTerminate.targetSentTimestamp!!
|
||||
|
||||
@@ -1159,6 +1169,11 @@ object DataMessageProcessor {
|
||||
senderRecipient: Recipient,
|
||||
earlyMessageCacheEntry: EarlyMessageCacheEntry?
|
||||
): MessageId? {
|
||||
if (!RemoteConfig.receivePolls) {
|
||||
log(envelope.timestamp!!, "Poll vote not allowed due to remote config.")
|
||||
return null
|
||||
}
|
||||
|
||||
val pollVote: DataMessage.PollVote = message.pollVote!!
|
||||
val targetSentTimestamp = pollVote.targetSentTimestamp!!
|
||||
|
||||
|
||||
@@ -102,6 +102,7 @@ import org.thoughtcrime.securesms.util.EarlyMessageCacheEntry
|
||||
import org.thoughtcrime.securesms.util.IdentityUtil
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import org.thoughtcrime.securesms.util.MessageConstraintsUtil
|
||||
import org.thoughtcrime.securesms.util.RemoteConfig
|
||||
import org.thoughtcrime.securesms.util.SignalE164Util
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
@@ -1740,6 +1741,10 @@ object SyncMessageProcessor {
|
||||
sent: Sent,
|
||||
senderRecipient: Recipient
|
||||
): Long {
|
||||
if (!RemoteConfig.receivePolls) {
|
||||
log(envelope.timestamp!!, "Sync poll create not allowed due to remote config.")
|
||||
}
|
||||
|
||||
log(envelope.timestamp!!, "Synchronize sent poll creation message.")
|
||||
|
||||
val recipient = getSyncMessageDestination(sent)
|
||||
@@ -1791,6 +1796,10 @@ object SyncMessageProcessor {
|
||||
senderRecipient: Recipient,
|
||||
earlyMessageCacheEntry: EarlyMessageCacheEntry?
|
||||
): Long {
|
||||
if (!RemoteConfig.receivePolls) {
|
||||
log(envelope.timestamp!!, "Sync poll end not allowed due to remote config.")
|
||||
}
|
||||
|
||||
log(envelope.timestamp!!, "Synchronize sent poll terminate message")
|
||||
|
||||
val recipient = getSyncMessageDestination(sent)
|
||||
|
||||
@@ -1181,5 +1181,12 @@ object RemoteConfig {
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@get:JvmName("receivePolls")
|
||||
val receivePolls: Boolean by remoteBoolean(
|
||||
key = "android.receivePolls",
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
)
|
||||
// endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user