Do not create new threads to show error messages.
This commit is contained in:
parent
80c0e19692
commit
2c2735af6d
2 changed files with 30 additions and 12 deletions
|
@ -351,6 +351,9 @@ open class MessageContentProcessor(private val context: Context) {
|
||||||
warn(timestamp, "Handling encryption error.")
|
warn(timestamp, "Handling encryption error.")
|
||||||
|
|
||||||
val threadRecipient = if (exceptionMetadata.groupId != null) Recipient.externalPossiblyMigratedGroup(exceptionMetadata.groupId) else sender
|
val threadRecipient = if (exceptionMetadata.groupId != null) Recipient.externalPossiblyMigratedGroup(exceptionMetadata.groupId) else sender
|
||||||
|
val threadId: Long? = SignalDatabase.threads.getThreadIdFor(threadRecipient.id)
|
||||||
|
|
||||||
|
if (threadId != null) {
|
||||||
SignalDatabase
|
SignalDatabase
|
||||||
.messages
|
.messages
|
||||||
.insertBadDecryptMessage(
|
.insertBadDecryptMessage(
|
||||||
|
@ -358,8 +361,11 @@ open class MessageContentProcessor(private val context: Context) {
|
||||||
senderDevice = exceptionMetadata.senderDevice,
|
senderDevice = exceptionMetadata.senderDevice,
|
||||||
sentTimestamp = timestamp,
|
sentTimestamp = timestamp,
|
||||||
receivedTimestamp = System.currentTimeMillis(),
|
receivedTimestamp = System.currentTimeMillis(),
|
||||||
threadId = SignalDatabase.threads.getOrCreateThreadIdFor(threadRecipient)
|
threadId = threadId
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
warn(timestamp, "Could not find a thread for the target recipient. Skipping.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageState.INVALID_VERSION -> {
|
MessageState.INVALID_VERSION -> {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import com.squareup.wire.internal.toUnmodifiableList
|
import com.squareup.wire.internal.toUnmodifiableList
|
||||||
import org.signal.core.util.PendingIntentFlags
|
import org.signal.core.util.PendingIntentFlags
|
||||||
|
import org.signal.core.util.isAbsent
|
||||||
import org.signal.core.util.logging.Log
|
import org.signal.core.util.logging.Log
|
||||||
import org.signal.core.util.roundedString
|
import org.signal.core.util.roundedString
|
||||||
import org.signal.libsignal.metadata.InvalidMetadataMessageException
|
import org.signal.libsignal.metadata.InvalidMetadataMessageException
|
||||||
|
@ -302,11 +303,22 @@ object MessageDecryptor {
|
||||||
|
|
||||||
followUpOperations += FollowUpOperation {
|
followUpOperations += FollowUpOperation {
|
||||||
val groupId: GroupId? = protocolException.parseGroupId(envelope)
|
val groupId: GroupId? = protocolException.parseGroupId(envelope)
|
||||||
val threadId: Long = if (groupId != null) {
|
|
||||||
|
val threadId: Long? = if (groupId != null) {
|
||||||
|
if (SignalDatabase.groups.getGroup(groupId).isAbsent()) {
|
||||||
|
Log.w(TAG, "${logPrefix(envelope)} No group found for $groupId! Not inserting a retry receipt.")
|
||||||
|
return@FollowUpOperation null
|
||||||
|
}
|
||||||
|
|
||||||
val groupRecipient: Recipient = Recipient.externalPossiblyMigratedGroup(groupId)
|
val groupRecipient: Recipient = Recipient.externalPossiblyMigratedGroup(groupId)
|
||||||
SignalDatabase.threads.getOrCreateThreadIdFor(groupRecipient)
|
SignalDatabase.threads.getThreadIdFor(groupRecipient.id)
|
||||||
} else {
|
} else {
|
||||||
SignalDatabase.threads.getOrCreateThreadIdFor(sender)
|
SignalDatabase.threads.getThreadIdFor(sender.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (threadId == null) {
|
||||||
|
Log.w(TAG, "${logPrefix(envelope)} Thread does not already exist for sender ${sender.id}! We will not create one just to show a retry receipt.")
|
||||||
|
return@FollowUpOperation null
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationDependencies.getPendingRetryReceiptCache().insert(sender.id, senderDevice, envelope.timestamp!!, receivedTimestamp, threadId)
|
ApplicationDependencies.getPendingRetryReceiptCache().insert(sender.id, senderDevice, envelope.timestamp!!, receivedTimestamp, threadId)
|
||||||
|
|
Loading…
Add table
Reference in a new issue