mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Always renew session when failing to decrypt message
This commit is contained in:
parent
6befda7ef1
commit
14b07be0dc
3 changed files with 5 additions and 17 deletions
|
@ -19,10 +19,8 @@ public class RenewSessionAction implements HandleAction {
|
||||||
@Override
|
@Override
|
||||||
public void execute(Context context) throws Throwable {
|
public void execute(Context context) throws Throwable {
|
||||||
context.getAccount().getAccountData(accountId).getSessionStore().archiveSessions(serviceId);
|
context.getAccount().getAccountData(accountId).getSessionStore().archiveSessions(serviceId);
|
||||||
if (!recipientId.equals(context.getAccount().getSelfRecipientId())) {
|
|
||||||
context.getSendHelper().sendNullMessage(recipientId);
|
context.getSendHelper().sendNullMessage(recipientId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.signal.libsignal.metadata.ProtocolException;
|
||||||
import org.signal.libsignal.protocol.message.CiphertextMessage;
|
import org.signal.libsignal.protocol.message.CiphertextMessage;
|
||||||
import org.signal.libsignal.protocol.message.DecryptionErrorMessage;
|
import org.signal.libsignal.protocol.message.DecryptionErrorMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
|
||||||
import org.whispersystems.signalservice.internal.push.Envelope;
|
import org.whispersystems.signalservice.internal.push.Envelope;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -15,29 +14,21 @@ import java.util.Optional;
|
||||||
public class SendRetryMessageRequestAction implements HandleAction {
|
public class SendRetryMessageRequestAction implements HandleAction {
|
||||||
|
|
||||||
private final RecipientId recipientId;
|
private final RecipientId recipientId;
|
||||||
private final ServiceId serviceId;
|
|
||||||
private final ProtocolException protocolException;
|
private final ProtocolException protocolException;
|
||||||
private final SignalServiceEnvelope envelope;
|
private final SignalServiceEnvelope envelope;
|
||||||
private final ServiceId accountId;
|
|
||||||
|
|
||||||
public SendRetryMessageRequestAction(
|
public SendRetryMessageRequestAction(
|
||||||
final RecipientId recipientId,
|
final RecipientId recipientId,
|
||||||
final ServiceId serviceId,
|
|
||||||
final ProtocolException protocolException,
|
final ProtocolException protocolException,
|
||||||
final SignalServiceEnvelope envelope,
|
final SignalServiceEnvelope envelope
|
||||||
final ServiceId accountId
|
|
||||||
) {
|
) {
|
||||||
this.recipientId = recipientId;
|
this.recipientId = recipientId;
|
||||||
this.serviceId = serviceId;
|
|
||||||
this.protocolException = protocolException;
|
this.protocolException = protocolException;
|
||||||
this.envelope = envelope;
|
this.envelope = envelope;
|
||||||
this.accountId = accountId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(Context context) throws Throwable {
|
public void execute(Context context) throws Throwable {
|
||||||
context.getAccount().getAccountData(accountId).getSessionStore().archiveSessions(serviceId);
|
|
||||||
|
|
||||||
int senderDevice = protocolException.getSenderDevice();
|
int senderDevice = protocolException.getSenderDevice();
|
||||||
Optional<GroupId> groupId = protocolException.getGroupId().isPresent() ? Optional.of(GroupId.unknownVersion(
|
Optional<GroupId> groupId = protocolException.getGroupId().isPresent() ? Optional.of(GroupId.unknownVersion(
|
||||||
protocolException.getGroupId().get())) : Optional.empty();
|
protocolException.getGroupId().get())) : Optional.empty();
|
||||||
|
|
|
@ -165,12 +165,11 @@ public final class IncomingMessageHandler {
|
||||||
if (serviceId != null) {
|
if (serviceId != null) {
|
||||||
final var isSelf = sender.equals(account.getSelfRecipientId())
|
final var isSelf = sender.equals(account.getSelfRecipientId())
|
||||||
&& e.getSenderDevice() == account.getDeviceId();
|
&& e.getSenderDevice() == account.getDeviceId();
|
||||||
if (!isSelf) {
|
|
||||||
logger.debug("Received invalid message, requesting message resend.");
|
|
||||||
actions.add(new SendRetryMessageRequestAction(sender, serviceId, e, envelope, destination));
|
|
||||||
} else {
|
|
||||||
logger.debug("Received invalid message, queuing renew session action.");
|
logger.debug("Received invalid message, queuing renew session action.");
|
||||||
actions.add(new RenewSessionAction(sender, serviceId, destination));
|
actions.add(new RenewSessionAction(sender, serviceId, destination));
|
||||||
|
if (!isSelf) {
|
||||||
|
logger.debug("Received invalid message, requesting message resend.");
|
||||||
|
actions.add(new SendRetryMessageRequestAction(sender, e, envelope));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Received invalid message from invalid sender: {}", e.getSender());
|
logger.debug("Received invalid message from invalid sender: {}", e.getSender());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue