From 8a8f31882a13c69218e49dacbfc7cb5266c52b9f Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Tue, 27 Dec 2016 23:31:21 +0100 Subject: deduplicate corrected messages --- src/main/java/de/pixart/messenger/entities/Message.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/pixart/messenger/entities/Message.java b/src/main/java/de/pixart/messenger/entities/Message.java index 14120908f..8ac7735d6 100644 --- a/src/main/java/de/pixart/messenger/entities/Message.java +++ b/src/main/java/de/pixart/messenger/entities/Message.java @@ -411,15 +411,18 @@ public class Message extends AbstractEntity { body = this.body; otherBody = message.body; } + final boolean matchingCounterpart = this.counterpart.equals(message.getCounterpart()); if (message.getRemoteMsgId() != null) { + final boolean hasUuid = CryptoHelper.UUID_PATTERN.matcher(message.getRemoteMsgId()).matches(); + if (hasUuid && this.edited != null && matchingCounterpart && this.edited.equals(message.getRemoteMsgId())) { + return true; + } return (message.getRemoteMsgId().equals(this.remoteMsgId) || message.getRemoteMsgId().equals(this.uuid)) - && this.counterpart.equals(message.getCounterpart()) - && (body.equals(otherBody) - || (message.getEncryption() == Message.ENCRYPTION_PGP - && CryptoHelper.UUID_PATTERN.matcher(message.getRemoteMsgId()).matches())); + && matchingCounterpart + && (body.equals(otherBody) ||(message.getEncryption() == Message.ENCRYPTION_PGP && hasUuid)); } else { return this.remoteMsgId == null - && this.counterpart.equals(message.getCounterpart()) + && matchingCounterpart && body.equals(otherBody) && Math.abs(this.getTimeSent() - message.getTimeSent()) < Config.MESSAGE_MERGE_WINDOW * 1000; } -- cgit v1.2.3