mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Update spam UX and reporting flows.
This commit is contained in:
committed by
Clark Chen
parent
a4fde60c1c
commit
aa76cefb1c
@@ -131,7 +131,18 @@ object DataMessageProcessor {
|
||||
|
||||
var groupProcessResult: MessageContentProcessor.Gv2PreProcessResult? = null
|
||||
if (groupId != null) {
|
||||
groupProcessResult = MessageContentProcessor.handleGv2PreProcessing(context, envelope.timestamp!!, content, metadata, groupId, message.groupV2!!, senderRecipient, groupSecretParams)
|
||||
groupProcessResult = MessageContentProcessor.handleGv2PreProcessing(
|
||||
context = context,
|
||||
timestamp = envelope.timestamp!!,
|
||||
content = content,
|
||||
metadata = metadata,
|
||||
groupId = groupId,
|
||||
groupV2 = message.groupV2!!,
|
||||
senderRecipient = senderRecipient,
|
||||
groupSecretParams = groupSecretParams,
|
||||
serverGuid = envelope.serverGuid
|
||||
)
|
||||
|
||||
if (groupProcessResult == MessageContentProcessor.Gv2PreProcessResult.IGNORE) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -228,10 +228,11 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
groupId: GroupId.V2,
|
||||
groupV2: GroupContextV2,
|
||||
senderRecipient: Recipient,
|
||||
groupSecretParams: GroupSecretParams? = null
|
||||
groupSecretParams: GroupSecretParams? = null,
|
||||
serverGuid: String? = null
|
||||
): Gv2PreProcessResult {
|
||||
val preUpdateGroupRecord = SignalDatabase.groups.getGroup(groupId)
|
||||
val groupUpdateResult = updateGv2GroupFromServerOrP2PChange(context, timestamp, groupV2, preUpdateGroupRecord, groupSecretParams)
|
||||
val groupUpdateResult = updateGv2GroupFromServerOrP2PChange(context, timestamp, groupV2, preUpdateGroupRecord, groupSecretParams, serverGuid)
|
||||
if (groupUpdateResult == null) {
|
||||
log(timestamp, "Ignoring GV2 message for group we are not currently in $groupId")
|
||||
return Gv2PreProcessResult.IGNORE
|
||||
@@ -272,13 +273,14 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
timestamp: Long,
|
||||
groupV2: GroupContextV2,
|
||||
localRecord: Optional<GroupRecord>,
|
||||
groupSecretParams: GroupSecretParams? = null
|
||||
groupSecretParams: GroupSecretParams? = null,
|
||||
serverGuid: String? = null
|
||||
): GroupsV2StateProcessor.GroupUpdateResult? {
|
||||
return try {
|
||||
val signedGroupChange: ByteArray? = if (groupV2.hasSignedGroupChange) groupV2.signedGroupChange else null
|
||||
val updatedTimestamp = if (signedGroupChange != null) timestamp else timestamp - 1
|
||||
if (groupV2.revision != null) {
|
||||
GroupManager.updateGroupFromServer(context, groupV2.groupMasterKey, localRecord, groupSecretParams, groupV2.revision!!, updatedTimestamp, signedGroupChange)
|
||||
GroupManager.updateGroupFromServer(context, groupV2.groupMasterKey, localRecord, groupSecretParams, groupV2.revision!!, updatedTimestamp, signedGroupChange, serverGuid)
|
||||
} else {
|
||||
warn(timestamp, "Ignore group update message without a revision")
|
||||
null
|
||||
|
||||
@@ -73,9 +73,6 @@ import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.toSignalServic
|
||||
import org.thoughtcrime.securesms.messages.SignalServiceProtoUtil.type
|
||||
import org.thoughtcrime.securesms.mms.MmsException
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMessage
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMessage.Companion.endSessionMessage
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMessage.Companion.expirationUpdateMessage
|
||||
import org.thoughtcrime.securesms.mms.OutgoingMessage.Companion.text
|
||||
import org.thoughtcrime.securesms.mms.QuoteModel
|
||||
import org.thoughtcrime.securesms.notifications.MarkReadReceiver
|
||||
import org.thoughtcrime.securesms.payments.MobileCoinPublicAddress
|
||||
@@ -122,6 +119,7 @@ import org.whispersystems.signalservice.internal.push.Verified
|
||||
import java.io.IOException
|
||||
import java.util.Optional
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.time.Duration
|
||||
|
||||
object SyncMessageProcessor {
|
||||
@@ -576,7 +574,7 @@ object SyncMessageProcessor {
|
||||
log(envelopeTimestamp, "Synchronize end session message.")
|
||||
|
||||
val recipient: Recipient = getSyncMessageDestination(sent)
|
||||
val outgoingEndSessionMessage: OutgoingMessage = endSessionMessage(recipient, sent.timestamp!!)
|
||||
val outgoingEndSessionMessage: OutgoingMessage = OutgoingMessage.endSessionMessage(recipient, sent.timestamp!!)
|
||||
val threadId: Long = SignalDatabase.threads.getOrCreateThreadIdFor(recipient)
|
||||
|
||||
if (!recipient.isGroup) {
|
||||
@@ -624,7 +622,7 @@ object SyncMessageProcessor {
|
||||
}
|
||||
|
||||
val recipient: Recipient = getSyncMessageDestination(sent)
|
||||
val expirationUpdateMessage: OutgoingMessage = expirationUpdateMessage(recipient, if (sideEffect) sent.timestamp!! - 1 else sent.timestamp!!, sent.message!!.expireTimerDuration.inWholeMilliseconds)
|
||||
val expirationUpdateMessage: OutgoingMessage = OutgoingMessage.expirationUpdateMessage(recipient, if (sideEffect) sent.timestamp!! - 1 else sent.timestamp!!, sent.message!!.expireTimerDuration.inWholeMilliseconds)
|
||||
val threadId: Long = SignalDatabase.threads.getOrCreateThreadIdFor(recipient)
|
||||
val messageId: Long = SignalDatabase.messages.insertMessageOutbox(expirationUpdateMessage, threadId, false, null)
|
||||
|
||||
@@ -830,7 +828,7 @@ object SyncMessageProcessor {
|
||||
messageId = SignalDatabase.messages.insertMessageOutbox(outgoingMessage, threadId, false, GroupReceiptTable.STATUS_UNKNOWN, null)
|
||||
updateGroupReceiptStatus(sent, messageId, recipient.requireGroupId())
|
||||
} else {
|
||||
val outgoingTextMessage = text(threadRecipient = recipient, body = body, expiresIn = expiresInMillis, sentTimeMillis = sent.timestamp!!, bodyRanges = bodyRanges)
|
||||
val outgoingTextMessage = OutgoingMessage.text(threadRecipient = recipient, body = body, expiresIn = expiresInMillis, sentTimeMillis = sent.timestamp!!, bodyRanges = bodyRanges)
|
||||
messageId = SignalDatabase.messages.insertMessageOutbox(outgoingTextMessage, threadId, false, null)
|
||||
SignalDatabase.messages.markUnidentified(messageId, sent.isUnidentified(recipient.serviceId.orNull()))
|
||||
}
|
||||
@@ -1058,6 +1056,12 @@ object SyncMessageProcessor {
|
||||
MessageRequestResponse.Type.ACCEPT -> {
|
||||
SignalDatabase.recipients.setProfileSharing(recipient.id, true)
|
||||
SignalDatabase.recipients.setBlocked(recipient.id, false)
|
||||
SignalDatabase.messages.insertMessageOutbox(
|
||||
OutgoingMessage.messageRequestAcceptMessage(recipient, System.currentTimeMillis(), TimeUnit.SECONDS.toMillis(recipient.expiresInSeconds.toLong())),
|
||||
threadId,
|
||||
false,
|
||||
null
|
||||
)
|
||||
}
|
||||
MessageRequestResponse.Type.DELETE -> {
|
||||
SignalDatabase.recipients.setProfileSharing(recipient.id, false)
|
||||
@@ -1076,6 +1080,24 @@ object SyncMessageProcessor {
|
||||
SignalDatabase.threads.deleteConversation(threadId)
|
||||
}
|
||||
}
|
||||
MessageRequestResponse.Type.SPAM -> {
|
||||
SignalDatabase.messages.insertMessageOutbox(
|
||||
OutgoingMessage.reportSpamMessage(recipient, System.currentTimeMillis(), TimeUnit.SECONDS.toMillis(recipient.expiresInSeconds.toLong())),
|
||||
threadId,
|
||||
false,
|
||||
null
|
||||
)
|
||||
}
|
||||
MessageRequestResponse.Type.BLOCK_AND_SPAM -> {
|
||||
SignalDatabase.recipients.setBlocked(recipient.id, true)
|
||||
SignalDatabase.recipients.setProfileSharing(recipient.id, false)
|
||||
SignalDatabase.messages.insertMessageOutbox(
|
||||
OutgoingMessage.reportSpamMessage(recipient, System.currentTimeMillis(), TimeUnit.SECONDS.toMillis(recipient.expiresInSeconds.toLong())),
|
||||
threadId,
|
||||
false,
|
||||
null
|
||||
)
|
||||
}
|
||||
else -> warn("Got an unknown response type! Skipping")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user