Request message resend if incoming message can't be decrypted

This commit is contained in:
AsamK 2021-09-12 13:13:45 +02:00
parent fbafa75fe2
commit 62d8873a92
7 changed files with 158 additions and 6 deletions

View file

@ -8,6 +8,7 @@ import org.asamk.signal.manager.groups.GroupUtils;
import org.asamk.signal.util.DateUtils;
import org.asamk.signal.util.Util;
import org.slf4j.helpers.MessageFormatter;
import org.whispersystems.libsignal.protocol.DecryptionErrorMessage;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
import org.whispersystems.signalservice.api.messages.SignalServiceContent;
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage;
@ -113,6 +114,11 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
var typingMessage = content.getTypingMessage().get();
printTypingMessage(writer.indentedWriter(), typingMessage);
}
if (content.getDecryptionErrorMessage().isPresent()) {
writer.println("Received a decryption error message (resend request)");
var decryptionErrorMessage = content.getDecryptionErrorMessage().get();
printDecryptionErrorMessage(writer.indentedWriter(), decryptionErrorMessage);
}
}
} else {
writer.println("Unknown message received.");
@ -215,6 +221,15 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
}
}
private void printDecryptionErrorMessage(
final PlainTextWriter writer, final DecryptionErrorMessage decryptionErrorMessage
) {
writer.println("Device id: {}", decryptionErrorMessage.getDeviceId());
writer.println("Timestamp: {}", DateUtils.formatTimestamp(decryptionErrorMessage.getTimestamp()));
writer.println("Ratchet key: {}",
decryptionErrorMessage.getRatchetKey().isPresent() ? "is present" : "not present");
}
private void printReceiptMessage(
final PlainTextWriter writer, final SignalServiceReceiptMessage receiptMessage
) {