aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java9
-rw-r--r--src/eu/siacs/conversations/entities/Message.java8
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java10
3 files changed, 25 insertions, 2 deletions
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index be641ea4..ce29301c 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -399,4 +399,13 @@ public class Conversation extends AbstractEntity {
return UIHelper.getContactPicture(this, size, context, false);
}
}
+
+ public boolean hasDuplicateMessage(Message message) {
+ for(int i = this.getMessages().size() -1; i >= 0; --i) {
+ if (this.messages.get(i).equals(message)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index b669efc5..6d70b66d 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -275,4 +275,12 @@ public class Message extends AbstractEntity {
public void setCounterpart(String counterpart) {
this.counterpart = counterpart;
}
+
+ public boolean equals(Message message) {
+ if ((this.remoteMsgId!=null) && (this.body != null) && (this.counterpart != null)) {
+ return this.remoteMsgId.equals(message.getRemoteMsgId()) && this.body.equals(message.getBody()) && this.counterpart.equals(message.getCounterpart());
+ } else {
+ return false;
+ }
+ }
}
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index e3cb1a1e..06c0923a 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -48,6 +48,7 @@ public class MessageParser extends AbstractParser implements
.getTrueCounterpart(fromParts[1]));
}
+ finishedMessage.setRemoteMsgId(packet.getId());
finishedMessage.setTime(getTimestamp(packet));
return finishedMessage;
}
@@ -113,6 +114,7 @@ public class MessageParser extends AbstractParser implements
packet.getFrom(), body, Message.ENCRYPTION_OTR,
Message.STATUS_RECIEVED);
finishedMessage.setTime(getTimestamp(packet));
+ finishedMessage.setRemoteMsgId(packet.getId());
return finishedMessage;
} catch (Exception e) {
String receivedId = packet.getId();
@@ -163,11 +165,15 @@ public class MessageParser extends AbstractParser implements
finishedMessage = new Message(conversation, counterPart, pgpBody,
Message.ENCRYPTION_PGP, status);
}
- finishedMessage.setTime(getTimestamp(packet));
+ finishedMessage.setRemoteMsgId(packet.getId());
if (status == Message.STATUS_RECIEVED) {
finishedMessage.setTrueCounterpart(conversation.getMucOptions()
.getTrueCounterpart(counterPart));
}
+ if (packet.hasChild("delay") && conversation.hasDuplicateMessage(finishedMessage)) {
+ return null;
+ }
+ finishedMessage.setTime(getTimestamp(packet));
return finishedMessage;
}
@@ -223,7 +229,7 @@ public class MessageParser extends AbstractParser implements
Message.ENCRYPTION_NONE, status);
}
finishedMessage.setTime(getTimestamp(message));
-
+ finishedMessage.setRemoteMsgId(message.getAttribute("id"));
if (conversation.getMode() == Conversation.MODE_MULTI
&& parts.length >= 2) {
finishedMessage.setType(Message.TYPE_PRIVATE);