From 47b982524e21ac3a58d742092943eef3e8edb7e1 Mon Sep 17 00:00:00 2001 From: lookshe Date: Mon, 21 Mar 2016 03:11:02 +0100 Subject: One more fix in Message.equals() (FS#104) --- .../conversationsplus/entities/Message.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src') 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); } } } -- cgit v1.2.3