diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-05-17 21:58:46 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-05-17 21:58:46 +0200 |
commit | 5a60dab1d5ead7a94d9d86cecc563210fed4b4bf (patch) | |
tree | 383ecee02d5fd06737fb7d4cfbfb2360c3c441ba /src/main/java/de/pixart/messenger/entities | |
parent | d1449161398a099db7f3c5e10ccfc07dd8cffe3b (diff) |
use mam reference instead of timestamp
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/entities/Conversation.java | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java index 15dc844b1..d95894d00 100644 --- a/src/main/java/de/pixart/messenger/entities/Conversation.java +++ b/src/main/java/de/pixart/messenger/entities/Conversation.java @@ -31,6 +31,7 @@ import de.pixart.messenger.services.XmppConnectionService; import de.pixart.messenger.xmpp.chatstate.ChatState; import de.pixart.messenger.xmpp.jid.InvalidJidException; import de.pixart.messenger.xmpp.jid.Jid; +import de.pixart.messenger.xmpp.mam.MamReference; public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation> { @@ -363,12 +364,16 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl return this.mFirstMamReference; } - public void setLastClearHistory(long time) { - setAttribute("ATTRIBUTE_LAST_CLEAR_HISTORY", String.valueOf(time)); + public void setLastClearHistory(long time, String reference) { + if (reference != null) { + setAttribute(ATTRIBUTE_LAST_CLEAR_HISTORY, String.valueOf(time) + ":" + reference); + } else { + setAttribute(ATTRIBUTE_LAST_CLEAR_HISTORY, String.valueOf(time)); + } } - public long getLastClearHistory() { - return getLongAttribute("ATTRIBUTE_LAST_CLEAR_HISTORY", 0); + public MamReference getLastClearHistory() { + return MamReference.fromAttribute(getAttribute(ATTRIBUTE_LAST_CLEAR_HISTORY)); } public List<Jid> getAcceptedCryptoTargets() { @@ -482,11 +487,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl if (this.messages.size() == 0) { Message message = new Message(this, "", Message.ENCRYPTION_NONE); message.setType(Message.TYPE_STATUS); - message.setTime(Math.max(getCreated(), getLastClearHistory())); + message.setTime(Math.max(getCreated(), getLastClearHistory().getTimestamp())); return message; } else { - Message message = this.messages.get(this.messages.size() - 1); - return message; + return this.messages.get(this.messages.size() - 1); } } @@ -854,19 +858,19 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl } } - public long getLastMessageTransmitted() { - final long last_clear = getLastClearHistory(); - long last_received = 0; + public MamReference getLastMessageTransmitted() { + final MamReference lastClear = getLastClearHistory(); + MamReference lastReceived = new MamReference(0); synchronized (this.messages) { for (int i = this.messages.size() - 1; i >= 0; --i) { Message message = this.messages.get(i); if (message.getStatus() == Message.STATUS_RECEIVED || message.isCarbon()) { - last_received = message.getTimeSent(); + lastReceived = new MamReference(message.getTimeSent(),message.getServerMsgId()); break; } } } - return Math.max(last_clear, last_received); + return MamReference.max(lastClear,lastReceived); } public void setMutedTill(long value) { |