mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Fix issues with receiving message to PNI address
This commit is contained in:
parent
6cd57312a1
commit
fd671576a4
2 changed files with 21 additions and 20 deletions
|
@ -64,6 +64,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.SignalServiceSy
|
|||
import org.whispersystems.signalservice.api.messages.multidevice.StickerPackOperationMessage;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId.ACI;
|
||||
import org.whispersystems.signalservice.api.push.ServiceIdType;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.internal.push.Envelope;
|
||||
import org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException;
|
||||
|
@ -100,8 +101,10 @@ public final class IncomingMessageHandler {
|
|||
SignalServiceContent content = null;
|
||||
if (!envelope.isReceipt()) {
|
||||
account.getIdentityKeyStore().setRetryingDecryption(true);
|
||||
final var destination = getDestination(envelope).serviceId();
|
||||
try {
|
||||
final var cipherResult = dependencies.getCipher()
|
||||
final var cipherResult = dependencies.getCipher(destination == null
|
||||
|| destination.equals(account.getAci()) ? ServiceIdType.ACI : ServiceIdType.PNI)
|
||||
.decrypt(envelope.getProto(), envelope.getServerDeliveredTimestamp());
|
||||
content = validate(envelope.getProto(), cipherResult, envelope.getServerDeliveredTimestamp());
|
||||
if (content == null) {
|
||||
|
@ -136,8 +139,10 @@ public final class IncomingMessageHandler {
|
|||
// uuid in envelope is sent by server
|
||||
.ifPresent(serviceId -> account.getRecipientResolver().resolveRecipient(serviceId));
|
||||
if (!envelope.isReceipt()) {
|
||||
final var destination = getDestination(envelope).serviceId();
|
||||
try {
|
||||
final var cipherResult = dependencies.getCipher()
|
||||
final var cipherResult = dependencies.getCipher(destination == null
|
||||
|| destination.equals(account.getAci()) ? ServiceIdType.ACI : ServiceIdType.PNI)
|
||||
.decrypt(envelope.getProto(), envelope.getServerDeliveredTimestamp());
|
||||
content = validate(envelope.getProto(), cipherResult, envelope.getServerDeliveredTimestamp());
|
||||
if (content == null) {
|
||||
|
@ -173,7 +178,6 @@ public final class IncomingMessageHandler {
|
|||
.contains(Profile.Capability.senderKey);
|
||||
final var isSelfSenderKeyCapable = selfProfile != null && selfProfile.getCapabilities()
|
||||
.contains(Profile.Capability.senderKey);
|
||||
final var destination = getDestination(envelope).serviceId();
|
||||
if (!isSelf && isSenderSenderKeyCapable && isSelfSenderKeyCapable) {
|
||||
logger.debug("Received invalid message, requesting message resend.");
|
||||
actions.add(new SendRetryMessageRequestAction(sender, serviceId, e, envelope, destination));
|
||||
|
@ -953,16 +957,12 @@ public final class IncomingMessageHandler {
|
|||
}
|
||||
|
||||
private DeviceAddress getDestination(SignalServiceEnvelope envelope) {
|
||||
if (!envelope.hasDestinationUuid()) {
|
||||
final var destination = envelope.getDestinationServiceId();
|
||||
if (destination == null) {
|
||||
return new DeviceAddress(account.getSelfRecipientId(), account.getAci(), account.getDeviceId());
|
||||
}
|
||||
final var addressOptional = SignalServiceAddress.fromRaw(envelope.getDestinationServiceId(), null);
|
||||
if (addressOptional.isEmpty()) {
|
||||
return new DeviceAddress(account.getSelfRecipientId(), account.getAci(), account.getDeviceId());
|
||||
}
|
||||
final var address = addressOptional.get();
|
||||
return new DeviceAddress(account.getRecipientResolver().resolveRecipient(address),
|
||||
address.getServiceId(),
|
||||
return new DeviceAddress(account.getRecipientResolver().resolveRecipient(destination),
|
||||
destination,
|
||||
account.getDeviceId());
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.whispersystems.signalservice.api.crypto.SignalServiceCipher;
|
|||
import org.whispersystems.signalservice.api.groupsv2.ClientZkOperations;
|
||||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Api;
|
||||
import org.whispersystems.signalservice.api.groupsv2.GroupsV2Operations;
|
||||
import org.whispersystems.signalservice.api.push.ServiceIdType;
|
||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||
import org.whispersystems.signalservice.api.services.ProfileService;
|
||||
import org.whispersystems.signalservice.api.svr.SecureValueRecovery;
|
||||
|
@ -53,7 +54,6 @@ public class SignalDependencies {
|
|||
|
||||
private List<SecureValueRecovery> secureValueRecoveryV2;
|
||||
private ProfileService profileService;
|
||||
private SignalServiceCipher cipher;
|
||||
|
||||
SignalDependencies(
|
||||
final ServiceEnvironmentConfig serviceEnvironmentConfig,
|
||||
|
@ -77,7 +77,6 @@ public class SignalDependencies {
|
|||
this.pushServiceSocket = null;
|
||||
}
|
||||
this.messageSender = null;
|
||||
this.cipher = null;
|
||||
getSignalWebSocket().forceNewWebSockets();
|
||||
}
|
||||
|
||||
|
@ -208,13 +207,15 @@ public class SignalDependencies {
|
|||
getSignalWebSocket()));
|
||||
}
|
||||
|
||||
public SignalServiceCipher getCipher() {
|
||||
return getOrCreate(() -> cipher, () -> {
|
||||
public SignalServiceCipher getCipher(ServiceIdType serviceIdType) {
|
||||
final var certificateValidator = new CertificateValidator(serviceEnvironmentConfig.unidentifiedSenderTrustRoot());
|
||||
final var address = new SignalServiceAddress(credentialsProvider.getAci(), credentialsProvider.getE164());
|
||||
final var deviceId = credentialsProvider.getDeviceId();
|
||||
cipher = new SignalServiceCipher(address, deviceId, dataStore.aci(), sessionLock, certificateValidator);
|
||||
});
|
||||
return new SignalServiceCipher(address,
|
||||
deviceId,
|
||||
serviceIdType == ServiceIdType.ACI ? dataStore.aci() : dataStore.pni(),
|
||||
sessionLock,
|
||||
certificateValidator);
|
||||
}
|
||||
|
||||
private <T> T getOrCreate(Supplier<T> supplier, Callable creator) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue