diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-01-29 12:09:31 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel@gultsch.de> | 2016-01-29 12:09:31 +0100 |
commit | 28ebf927fb6cadc64a4f138cb84bac91c9903fdf (patch) | |
tree | 97cd1af58135d932ad08a2ef33a0c8fc2369e83a /src | |
parent | d2c5a939ed2cf42374e0ddb528ee363b7fefee8c (diff) |
try to make in-valid-session detection work for pgp
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/eu/siacs/conversations/entities/Message.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index c5831e7e..f3d891e8 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -743,13 +743,20 @@ public class Message extends AbstractEntity { } public boolean isValidInSession() { - int pastEncryption = this.getPreviousEncryption(); - int futureEncryption = this.getNextEncryption(); + int pastEncryption = getCleanedEncryption(this.getPreviousEncryption()); + int futureEncryption = getCleanedEncryption(this.getNextEncryption()); boolean inUnencryptedSession = pastEncryption == ENCRYPTION_NONE || futureEncryption == ENCRYPTION_NONE || pastEncryption != futureEncryption; - return inUnencryptedSession || this.getEncryption() == pastEncryption; + return inUnencryptedSession || getCleanedEncryption(this.getEncryption()) == pastEncryption; + } + + private static int getCleanedEncryption(int encryption) { + if (encryption == ENCRYPTION_DECRYPTED || encryption == ENCRYPTION_DECRYPTION_FAILED) { + return ENCRYPTION_PGP; + } + return encryption; } } |