Add additional group terminate checks to message processing.

Co-authored-by: Cody Henthorne <cody@signal.org>
This commit is contained in:
jeffrey-signal
2026-03-31 10:18:59 -04:00
committed by Alex Hart
parent 966e208be5
commit b0f7c36cc2
2 changed files with 22 additions and 7 deletions

View File

@@ -570,6 +570,12 @@ open class MessageContentProcessor(private val context: Context) {
} }
val groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId) val groupRecipient = Recipient.externalPossiblyMigratedGroup(groupId)
if (!groupRecipient.isActiveGroup) {
warn(envelope.clientTimestamp!!, "Seen typing indicator for inactive group " + senderRecipient.id)
return
}
SignalDatabase.threads.getOrCreateThreadIdFor(groupRecipient) SignalDatabase.threads.getOrCreateThreadIdFor(groupRecipient)
} else { } else {
SignalDatabase.threads.getOrCreateThreadIdFor(senderRecipient) SignalDatabase.threads.getOrCreateThreadIdFor(senderRecipient)

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.messages package org.thoughtcrime.securesms.messages
import android.content.Context import android.content.Context
import androidx.annotation.WorkerThread
import com.mobilecoin.lib.exceptions.SerializationException import com.mobilecoin.lib.exceptions.SerializationException
import org.signal.core.models.AccountEntropyPool import org.signal.core.models.AccountEntropyPool
import org.signal.core.models.ServiceId import org.signal.core.models.ServiceId
@@ -139,7 +140,6 @@ import org.whispersystems.signalservice.internal.push.SyncMessage.StickerPackOpe
import org.whispersystems.signalservice.internal.push.SyncMessage.ViewOnceOpen import org.whispersystems.signalservice.internal.push.SyncMessage.ViewOnceOpen
import org.whispersystems.signalservice.internal.push.Verified import org.whispersystems.signalservice.internal.push.Verified
import java.io.IOException import java.io.IOException
import java.util.Optional
import java.util.UUID import java.util.UUID
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import kotlin.time.Duration import kotlin.time.Duration
@@ -149,6 +149,7 @@ import org.whispersystems.signalservice.internal.util.Util as Utils
object SyncMessageProcessor { object SyncMessageProcessor {
@WorkerThread
fun process( fun process(
context: Context, context: Context,
senderRecipient: Recipient, senderRecipient: Recipient,
@@ -352,7 +353,12 @@ object SyncMessageProcessor {
} else if (MessageConstraintsUtil.isValidEditMessageReceive(targetMessage, senderRecipient, envelope.serverTimestamp!!)) { } else if (MessageConstraintsUtil.isValidEditMessageReceive(targetMessage, senderRecipient, envelope.serverTimestamp!!)) {
val message: DataMessage = editMessage.dataMessage!! val message: DataMessage = editMessage.dataMessage!!
val toRecipient: Recipient = if (message.hasGroupContext) { val toRecipient: Recipient = if (message.hasGroupContext) {
Recipient.externalPossiblyMigratedGroup(GroupId.v2(message.groupV2!!.groupMasterKey)) val groupRecipient = Recipient.externalPossiblyMigratedGroup(GroupId.v2(message.groupV2!!.groupMasterKey))
if (!groupRecipient.isActiveGroup) {
warn(envelope.clientTimestamp!!, "[handleSynchronizeSentEditMessage] Group is inactive, skipping sync edit message")
return
}
groupRecipient
} else { } else {
Recipient.externalPush(ServiceId.parseOrThrow(sent.destinationServiceId, sent.destinationServiceIdBinary)) Recipient.externalPush(ServiceId.parseOrThrow(sent.destinationServiceId, sent.destinationServiceIdBinary))
} }
@@ -523,10 +529,16 @@ object SyncMessageProcessor {
val storyMessage: StoryMessage = sent.storyMessage!! val storyMessage: StoryMessage = sent.storyMessage!!
val distributionIds: Set<DistributionId> = manifest.getDistributionIdSet() val distributionIds: Set<DistributionId> = manifest.getDistributionIdSet()
val groupId: GroupId.V2? = storyMessage.group?.groupId val groupId: GroupId.V2? = storyMessage.group?.groupId
val groupRecipient: Recipient? = groupId?.let { SignalDatabase.recipients.getByGroupId(groupId) }?.map { Recipient.resolved(it) }?.orElse(null)
val textStoryBody: String? = StoryMessageProcessor.serializeTextAttachment(storyMessage) val textStoryBody: String? = StoryMessageProcessor.serializeTextAttachment(storyMessage)
val bodyRanges: BodyRangeList? = storyMessage.bodyRanges.toBodyRangeList() val bodyRanges: BodyRangeList? = storyMessage.bodyRanges.toBodyRangeList()
val storyType: StoryType = storyMessage.type val storyType: StoryType = storyMessage.type
if (groupRecipient != null && !groupRecipient.isActiveGroup) {
warn(envelope.clientTimestamp!!, "Group recipient is not active! Skipping story send sync")
return
}
val linkPreviews: List<LinkPreview> = DataMessageProcessor.getLinkPreviews( val linkPreviews: List<LinkPreview> = DataMessageProcessor.getLinkPreviews(
previews = listOfNotNull(storyMessage.textAttachment?.preview), previews = listOfNotNull(storyMessage.textAttachment?.preview),
body = "", body = "",
@@ -541,11 +553,8 @@ object SyncMessageProcessor {
insertSentStoryMessage(sent, distributionListRecipient, null, textStoryBody, attachments, sent.timestamp!!, storyType, linkPreviews, bodyRanges) insertSentStoryMessage(sent, distributionListRecipient, null, textStoryBody, attachments, sent.timestamp!!, storyType, linkPreviews, bodyRanges)
} }
if (groupId != null) { if (groupRecipient != null) {
val groupRecipient: Optional<RecipientId> = SignalDatabase.recipients.getByGroupId(groupId) insertSentStoryMessage(sent, groupRecipient, groupId, textStoryBody, attachments, sent.timestamp!!, storyType, linkPreviews, bodyRanges)
if (groupRecipient.isPresent) {
insertSentStoryMessage(sent, Recipient.resolved(groupRecipient.get()), groupId, textStoryBody, attachments, sent.timestamp!!, storyType, linkPreviews, bodyRanges)
}
} }
SignalDatabase.storySends.applySentStoryManifest(manifest, sent.timestamp!!) SignalDatabase.storySends.applySentStoryManifest(manifest, sent.timestamp!!)