aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/entities/Conversation.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-02-17 16:51:36 +0100
committerDaniel Gultsch <daniel@gultsch.de>2016-02-17 16:51:36 +0100
commit59978e157ccbf4717a15238ddb0b0d0d422d7e3f (patch)
tree1d01b8da5f741afd2c69fbb8fef259257af5d05f /src/main/java/eu/siacs/conversations/entities/Conversation.java
parent3626e4b3a0d3d3da4be1bdf7645045d8cf892b50 (diff)
only offer message correction for the very last message
Diffstat (limited to 'src/main/java/eu/siacs/conversations/entities/Conversation.java')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Conversation.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Conversation.java b/src/main/java/eu/siacs/conversations/entities/Conversation.java
index c72ac09e..a179d96b 100644
--- a/src/main/java/eu/siacs/conversations/entities/Conversation.java
+++ b/src/main/java/eu/siacs/conversations/entities/Conversation.java
@@ -227,11 +227,18 @@ public class Conversation extends AbstractEntity implements Blockable {
return null;
}
- public Message findMessageWithRemoteIdAndCounterpart(String id, Jid counterpart) {
+ public Message findMessageWithRemoteIdAndCounterpart(String id, Jid counterpart, boolean received, boolean carbon) {
synchronized (this.messages) {
- for(Message message : this.messages) {
- if(id.equals(message.getRemoteMsgId()) && counterpart.equals(message.getCounterpart())) {
- return message;
+ for(int i = this.messages.size() - 1; i >= 0; --i) {
+ Message message = messages.get(i);
+ if (counterpart.equals(message.getCounterpart())
+ && ((message.getStatus() == Message.STATUS_RECEIVED) == received)
+ && (carbon == message.isCarbon() || received) ) {
+ if (id.equals(message.getRemoteMsgId())) {
+ return message;
+ } else {
+ return null;
+ }
}
}
}