aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/parser
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-11-22 21:00:33 +0100
committerChristian Schneppe <christian@pix-art.de>2017-11-22 21:49:45 +0100
commit72df864d41e91d184dd20178d48e7b68df13e725 (patch)
tree0aae3068c35f175549d70232adf72e24ea393561 /src/main/java/de/pixart/messenger/parser
parentacdb88839648405e0498d7774bcdc9f422ebc5c2 (diff)
send and show read markers in private, non-anonymous groups
Diffstat (limited to 'src/main/java/de/pixart/messenger/parser')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 54a4571cc..d5003dc11 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -29,6 +29,7 @@ import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.Message;
import de.pixart.messenger.entities.MucOptions;
import de.pixart.messenger.entities.Presence;
+import de.pixart.messenger.entities.ReadByMarker;
import de.pixart.messenger.entities.ServiceDiscoveryResult;
import de.pixart.messenger.http.HttpConnectionManager;
import de.pixart.messenger.services.MessageArchiveService;
@@ -686,13 +687,36 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
Element displayed = packet.findChild("displayed", "urn:xmpp:chat-markers:0");
if (displayed != null) {
+ final String id = displayed.getAttribute("id");
if (packet.fromAccount(account)) {
Conversation conversation = mXmppConnectionService.find(account, counterpart.toBareJid());
if (conversation != null && (query == null || query.isCatchup())) {
mXmppConnectionService.markRead(conversation);
}
+ } else if (isTypeGroupChat) {
+ Conversation conversation = mXmppConnectionService.find(account, counterpart.toBareJid());
+ if (conversation != null && id != null) {
+ Message message = conversation.findMessageWithRemoteId(id);
+ if (message != null) {
+ if (conversation.getMucOptions().isSelf(counterpart)) {
+ if (!message.isRead() && (query == null || query.isCatchup())) { //checking if message is unread fixes race conditions with reflections
+ mXmppConnectionService.markRead(conversation);
+ }
+ } else {
+ final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
+ Jid trueJid = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
+ ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid);
+ if (message.addReadByMarker(readByMarker)) {
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'");
+ mXmppConnectionService.markMessage(message, Message.STATUS_SEND_DISPLAYED);
+ mXmppConnectionService.updateMessage(message);
+ }
+ }
+ }
+
+ }
} else {
- final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), displayed.getAttribute("id"), Message.STATUS_SEND_DISPLAYED);
+ final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), id, Message.STATUS_SEND_DISPLAYED);
Message message = displayedMessage == null ? null : displayedMessage.prev();
while (message != null
&& message.getStatus() == Message.STATUS_SEND_RECEIVED