aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/entities
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-20 17:28:39 +0100
committerlookshe <github@lookshe.org>2016-03-20 17:28:39 +0100
commitea6564c81a23c10bcdabeba7e29211e97c444d5b (patch)
tree88a2374b6254006e2aa9140e396a41f3fa3b20a9 /src/main/java/de/thedevstack/conversationsplus/entities
parent90bbe035e9efdff72241c8a0d87000fdba482a6b (diff)
FS#104 - Fix Message.equals()
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/entities')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/entities/Message.java32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
index 8dbb0535..c17995c9 100644
--- a/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
+++ b/src/main/java/de/thedevstack/conversationsplus/entities/Message.java
@@ -360,29 +360,25 @@ 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.getBody() == null || this.counterpart == null) {
+ if (this.getServerMsgId() != null && message.getServerMsgId() != null) {
+ return this.getServerMsgId().equals(message.getServerMsgId());
+ } else if (this.getBody() == null || this.getCounterpart() == null
+ || message.getBody() == null || message.getCounterpart() == null) {
return false;
} else {
- String body, otherBody;
- if (this.hasFileOnRemoteHost()) {
- body = getFileParams().url.toString();
- otherBody = message.getBody() == null ? null : message.getBody();
- } else {
- body = this.getBody();
- otherBody = message.getBody();
- }
- if (message.getRemoteMsgId() != null) {
- return (message.getRemoteMsgId().equals(this.remoteMsgId) || message.getRemoteMsgId().equals(this.uuid))
- && this.counterpart.equals(message.getCounterpart())
- && (body.equals(otherBody)
+ 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())
||(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.remoteMsgId == null
- && this.counterpart.equals(message.getCounterpart())
- && body.equals(otherBody);
+ return this.getRemoteMsgId() == null
+ && message.getRemoteMsgId() == null
+ && this.getCounterpart().equals(message.getCounterpart())
+ && this.getBody().equals(message.getBody());
}
}
}