diff options
author | lookshe <github@lookshe.org> | 2016-03-21 03:11:02 +0100 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2016-03-21 03:11:02 +0100 |
commit | 47b982524e21ac3a58d742092943eef3e8edb7e1 (patch) | |
tree | 116feb2ca4a61024524fa278c44e0dd4b833959c /src/main/java/de/thedevstack/conversationsplus | |
parent | 00fc37b326c3255af2f1592dde909b21e112f46f (diff) |
One more fix in Message.equals() (FS#104)
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/entities/Message.java | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java index c17995c9..39fcdfb2 100644 --- a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java +++ b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java @@ -366,19 +366,34 @@ public class Message extends AbstractEntity { || message.getBody() == null || message.getCounterpart() == null) { return false; } else { + String body, otherBody; + if (this.hasFileOnRemoteHost()) { + body = this.getFileParams().url.toString(); + } else { + body = this.getBody(); + } + if (message.hasFileOnRemoteHost()) { + otherBody = message.getFileParams().url.toString(); + } else { + otherBody = message.getBody(); + } + if (message.getRemoteMsgId() != null && this.getRemoteMsgId() != null) { return (message.getRemoteMsgId().equals(this.getRemoteMsgId()) || message.getRemoteMsgId().equals(this.getUuid()) || message.getUuid().equals(this.getRemoteMsgId())) && this.getCounterpart().equals(message.getCounterpart()) - && (this.getBody().equals(message.getBody()) + && (body.equals(otherBody) ||(message.getEncryption() == Message.ENCRYPTION_PGP && message.getRemoteMsgId().matches("[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"))) ; } else { - return this.getRemoteMsgId() == null - && message.getRemoteMsgId() == null + // existing (send) message with no remoteMsgId and MAM message with remoteMsgId + return ((this.getRemoteMsgId() == null && message.getRemoteMsgId() != null) + || (this.getRemoteMsgId() != null && message.getRemoteMsgId() == null) + // both null is also acceptable + || (this.getRemoteMsgId() == null && message.getRemoteMsgId() == null)) && this.getCounterpart().equals(message.getCounterpart()) - && this.getBody().equals(message.getBody()); + && body.equals(otherBody); } } } |