mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-28 18:10:38 +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,9 +19,7 @@ public class RenewSessionAction implements HandleAction {
|
|||
@Override
|
||||
public void execute(Context context) throws Throwable {
|
||||
context.getAccount().getAccountData(accountId).getSessionStore().archiveSessions(serviceId);
|
||||
if (!recipientId.equals(context.getAccount().getSelfRecipientId())) {
|
||||
context.getSendHelper().sendNullMessage(recipientId);
|
||||
}
|
||||
context.getSendHelper().sendNullMessage(recipientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,6 @@ import org.signal.libsignal.metadata.ProtocolException;
|
|||
import org.signal.libsignal.protocol.message.CiphertextMessage;
|
||||
import org.signal.libsignal.protocol.message.DecryptionErrorMessage;
|
||||
import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||
import org.whispersystems.signalservice.api.push.ServiceId;
|
||||
import org.whispersystems.signalservice.internal.push.Envelope;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -15,29 +14,21 @@ import java.util.Optional;
|
|||
public class SendRetryMessageRequestAction implements HandleAction {
|
||||
|
||||
private final RecipientId recipientId;
|
||||
private final ServiceId serviceId;
|
||||
private final ProtocolException protocolException;
|
||||
private final SignalServiceEnvelope envelope;
|
||||
private final ServiceId accountId;
|
||||
|
||||
public SendRetryMessageRequestAction(
|
||||
final RecipientId recipientId,
|
||||
final ServiceId serviceId,
|
||||
final ProtocolException protocolException,
|
||||
final SignalServiceEnvelope envelope,
|
||||
final ServiceId accountId
|
||||
final SignalServiceEnvelope envelope
|
||||
) {
|
||||
this.recipientId = recipientId;
|
||||
this.serviceId = serviceId;
|
||||
this.protocolException = protocolException;
|
||||
this.envelope = envelope;
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(Context context) throws Throwable {
|
||||
context.getAccount().getAccountData(accountId).getSessionStore().archiveSessions(serviceId);
|
||||
|
||||
int senderDevice = protocolException.getSenderDevice();
|
||||
Optional<GroupId> groupId = protocolException.getGroupId().isPresent() ? Optional.of(GroupId.unknownVersion(
|
||||
protocolException.getGroupId().get())) : Optional.empty();
|
||||
|
|
|
@ -165,12 +165,11 @@ public final class IncomingMessageHandler {
|
|||
if (serviceId != null) {
|
||||
final var isSelf = sender.equals(account.getSelfRecipientId())
|
||||
&& e.getSenderDevice() == account.getDeviceId();
|
||||
logger.debug("Received invalid message, queuing renew session action.");
|
||||
actions.add(new RenewSessionAction(sender, serviceId, destination));
|
||||
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.");
|
||||
actions.add(new RenewSessionAction(sender, serviceId, destination));
|
||||
actions.add(new SendRetryMessageRequestAction(sender, e, envelope));
|
||||
}
|
||||
} else {
|
||||
logger.debug("Received invalid message from invalid sender: {}", e.getSender());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue