From 7839438f513c101f831ec47b3d0224df07835e51 Mon Sep 17 00:00:00 2001 From: iNPUTmice Date: Tue, 20 Jan 2015 22:54:58 +0100 Subject: [PATCH] changed message duplicate finder --- .../eu/siacs/conversations/entities/Message.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Message.java b/src/main/java/eu/siacs/conversations/entities/Message.java index c25b300b4..55a1d2ce3 100644 --- a/src/main/java/eu/siacs/conversations/entities/Message.java +++ b/src/main/java/eu/siacs/conversations/entities/Message.java @@ -311,12 +311,17 @@ public class Message extends AbstractEntity { public boolean equals(Message message) { if (this.serverMsgId != null && message.getServerMsgId() != null) { return this.serverMsgId.equals(message.getServerMsgId()); + } else if (this.body == null || this.counterpart == null) { + return false; + } else if (message.getRemoteMsgId() != null) { + return (message.getRemoteMsgId().equals(this.remoteMsgId) || message.getRemoteMsgId().equals(this.uuid)) + && this.counterpart.equals(message.getCounterpart()) + && this.body.equals(message.getBody()); } else { - return this.body != null - && this.counterpart != null - && ((this.remoteMsgId != null && this.remoteMsgId.equals(message.getRemoteMsgId())) - || this.uuid.equals(message.getRemoteMsgId())) && this.body.equals(message.getBody()) - && this.counterpart.equals(message.getCounterpart()); + return this.remoteMsgId == null + && this.counterpart.equals(message.getCounterpart()) + && this.body.equals(message.getBody()) + && Math.abs(this.getTimeSent() - message.getTimeSent()) < Config.PING_TIMEOUT * 500; } }