Fix call requests to a PNI.

This commit is contained in:
Cody Henthorne
2025-10-27 09:52:17 -04:00
committed by jeffrey-signal
parent 55617c18f0
commit 76e92f29b9
7 changed files with 129 additions and 21 deletions

View File

@@ -1,12 +1,15 @@
package org.thoughtcrime.securesms.messages
import org.signal.core.util.orNull
import org.signal.ringrtc.CallId
import org.thoughtcrime.securesms.database.model.IdentityRecord
import org.thoughtcrime.securesms.dependencies.AppDependencies
import org.thoughtcrime.securesms.jobs.ProfileKeySendJob
import org.thoughtcrime.securesms.messages.MessageContentProcessor.Companion.log
import org.thoughtcrime.securesms.messages.MessageContentProcessor.Companion.warn
import org.thoughtcrime.securesms.recipients.Recipient
import org.thoughtcrime.securesms.recipients.RecipientId
import org.thoughtcrime.securesms.recipients.RecipientUtil
import org.thoughtcrime.securesms.ringrtc.RemotePeer
import org.thoughtcrime.securesms.service.webrtc.WebRtcData.AnswerMetadata
import org.thoughtcrime.securesms.service.webrtc.WebRtcData.CallMetadata
@@ -36,6 +39,21 @@ object CallMessageProcessor {
) {
val callMessage = content.callMessage!!
if (metadata.destinationServiceId is ServiceId.PNI) {
if (RecipientUtil.isCallRequestAccepted(senderRecipient) && callMessage.offer != null) {
log(envelope.timestamp!!, "Received call offer message at our PNI from trusted sender, responding with profile and pni signature")
RecipientUtil.shareProfileIfFirstSecureMessage(senderRecipient)
ProfileKeySendJob.create(senderRecipient, false)?.let { AppDependencies.jobManager.add(it) }
}
if (callMessage.offer != null) {
log(envelope.timestamp!!, "Call message at our PNI is an offer, continuing.")
} else {
log(envelope.timestamp!!, "Call message at our PNI is not an offer, ignoring.")
return
}
}
when {
callMessage.offer != null -> handleCallOfferMessage(envelope, metadata, callMessage.offer!!, senderRecipient.id, serverDeliveredTimestamp)
callMessage.answer != null -> handleCallAnswerMessage(envelope, metadata, callMessage.answer!!, senderRecipient.id)
@@ -57,13 +75,14 @@ object CallMessageProcessor {
}
val remotePeer = RemotePeer(senderRecipientId, CallId(offerId))
val remoteIdentityKey = AppDependencies.protocolStore.aci().identities().getIdentityRecord(senderRecipientId).map { (_, identityKey): IdentityRecord -> identityKey.serialize() }.get()
val remoteIdentityKey = AppDependencies.protocolStore.get(metadata.destinationServiceId).identities().getIdentityRecord(senderRecipientId).map { (_, identityKey): IdentityRecord -> identityKey.serialize() }.orNull()
AppDependencies.signalCallManager
.receivedOffer(
CallMetadata(remotePeer, metadata.sourceDeviceId),
OfferMetadata(offer.opaque?.toByteArray(), OfferMessage.Type.fromProto(offer.type!!)),
ReceivedOfferMetadata(
metadata.destinationServiceId,
remoteIdentityKey,
envelope.serverTimestamp!!,
serverDeliveredTimestamp

View File

@@ -146,7 +146,7 @@ object MessageDecryptor {
}
val bufferedStore = bufferedProtocolStore.get(destination)
val localAddress = SignalServiceAddress(selfAci, SignalStore.account.e164)
val localAddress = SignalServiceAddress(destination, SignalStore.account.e164)
val cipher = SignalServiceCipher(localAddress, SignalStore.account.deviceId, bufferedStore, ReentrantSessionLock.INSTANCE, SealedSenderAccessUtil.getCertificateValidator())
return try {