mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 00:59:49 +01:00
Improve and centralize e164 utils.
This commit is contained in:
@@ -342,7 +342,12 @@ open class MessageContentProcessor(private val context: Context) {
|
||||
}
|
||||
|
||||
fun processException(messageState: MessageState, exceptionMetadata: ExceptionMetadata, timestamp: Long) {
|
||||
val sender = Recipient.external(context, exceptionMetadata.sender)
|
||||
val sender = Recipient.external(exceptionMetadata.sender)
|
||||
|
||||
if (sender == null) {
|
||||
warn("Failed to create Recipient for identifier: $messageState")
|
||||
return
|
||||
}
|
||||
|
||||
if (sender.isBlocked) {
|
||||
warn("Ignoring exception content from blocked sender, message state: $messageState")
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.squareup.wire.internal.toUnmodifiableList
|
||||
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.logW
|
||||
import org.signal.core.util.roundedString
|
||||
import org.signal.libsignal.metadata.InvalidMetadataMessageException
|
||||
import org.signal.libsignal.metadata.InvalidMetadataVersionException
|
||||
@@ -223,8 +224,9 @@ object MessageDecryptor {
|
||||
Log.w(TAG, "${logPrefix(envelope, e)} Retry receipts disabled! Enqueuing a session reset job, which will also insert an error message.", e, true)
|
||||
|
||||
followUpOperations += FollowUpOperation {
|
||||
val sender: Recipient = Recipient.external(context, e.sender)
|
||||
AutomaticSessionResetJob(sender.id, e.senderDevice, envelope.timestamp!!).asChain()
|
||||
Recipient.external(e.sender)?.let {
|
||||
AutomaticSessionResetJob(it.id, e.senderDevice, envelope.timestamp!!).asChain()
|
||||
} ?: null.logW(TAG, "${logPrefix(envelope, e)} Failed to create a recipient with the provided identifier!")
|
||||
}
|
||||
|
||||
Result.Ignore(envelope, serverDeliveredTimestamp, followUpOperations.toUnmodifiableList())
|
||||
@@ -281,7 +283,7 @@ object MessageDecryptor {
|
||||
val contentHint: ContentHint = ContentHint.fromType(protocolException.contentHint)
|
||||
val senderDevice: Int = protocolException.senderDevice
|
||||
val receivedTimestamp: Long = System.currentTimeMillis()
|
||||
val sender: Recipient = Recipient.external(context, protocolException.sender)
|
||||
val sender: Recipient = Recipient.external(protocolException.sender) ?: return Result.Ignore(envelope, serverDeliveredTimestamp, followUpOperations)
|
||||
val senderServiceId: ServiceId? = ServiceId.parseOrNull(protocolException.sender)
|
||||
|
||||
if (sender.isSelf) {
|
||||
|
||||
@@ -99,6 +99,7 @@ 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
|
||||
import org.whispersystems.signalservice.api.crypto.EnvelopeMetadata
|
||||
@@ -1724,7 +1725,9 @@ object SyncMessageProcessor {
|
||||
}
|
||||
|
||||
threadE164 != null -> {
|
||||
SignalDatabase.recipients.getOrInsertFromE164(threadE164!!)
|
||||
SignalE164Util.formatAsE164(threadE164!!)?.let {
|
||||
SignalDatabase.recipients.getOrInsertFromE164(threadE164!!)
|
||||
}
|
||||
}
|
||||
|
||||
else -> null
|
||||
|
||||
Reference in New Issue
Block a user