]> nmode's Git Repositories - signal-cli/commitdiff
Don't retry messages if they fail for another reason than untrusted identity
authorAsamK <asamk@gmx.de>
Sat, 21 Nov 2020 10:51:31 +0000 (11:51 +0100)
committerAsamK <asamk@gmx.de>
Sat, 21 Nov 2020 10:51:31 +0000 (11:51 +0100)
src/main/java/org/asamk/signal/manager/Manager.java

index fc956266ec2ea7b8cc64aad4df5ea8072b05b035..add5b8546d29a6cbb5f1330922c059b5bcec9ec0 100644 (file)
@@ -1398,7 +1398,15 @@ public class Manager implements Closeable {
         if (!envelope.isReceipt()) {
             try {
                 content = decryptMessage(envelope);
-            } catch (Exception e) {
+            } catch (org.whispersystems.libsignal.UntrustedIdentityException e) {
+                return;
+            } catch (Exception er) {
+                // All other errors are not recoverable, so delete the cached message
+                try {
+                    Files.delete(fileEntry.toPath());
+                } catch (IOException e) {
+                    System.err.println("Failed to delete cached message file “" + fileEntry + "”: " + e.getMessage());
+                }
                 return;
             }
             List<HandleAction> actions = handleMessage(envelope, content, ignoreAttachments);
@@ -1476,6 +1484,7 @@ public class Manager implements Closeable {
                 System.err.println("Ignoring error: " + e.getMessage());
                 continue;
             }
+
             if (envelope.hasSource()) {
                 // Store uuid if we don't have it already
                 SignalServiceAddress source = envelope.getSourceAddress();