aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-03-09 19:43:52 +0100
committerChristian Schneppe <christian@pix-art.de>2017-03-09 19:43:52 +0100
commitcc7c118cc5c43aa7a3ebf49198b540e519fee0d6 (patch)
tree15e2d98ae2b4459edc92eb113ae7c8d6374ce42f /src/main/java/de/pixart/messenger
parentc9f70d07b936eaa53ebb1d443a32029202d42cd5 (diff)
extract stanza-id from muc reflections
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java34
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java5
2 files changed, 22 insertions, 17 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 1551f691a..a8cca22d7 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -212,6 +212,20 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
return null;
}
+ private static String extractStanzaid(Element packet, boolean isTypeGroupChat, Conversation conversation) {
+ final Jid by;
+ final boolean safeToExtract;
+ if (isTypeGroupChat) {
+ by = conversation.getJid().toBareJid();
+ safeToExtract = conversation.getMucOptions().hasFeature(Namespace.STANZA_IDS);
+ } else {
+ Account account = conversation.getAccount();
+ by = account.getJid().toBareJid();
+ safeToExtract = account.getXmppConnection().getFeatures().stanzaIds();
+ }
+ return safeToExtract ? extractStanzaId(packet, by) : null;
+ }
+
private static String extractStanzaId(Element packet, Jid by) {
for (Element child : packet.getChildren()) {
if (child.getName().equals("stanza-id")
@@ -384,11 +398,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if ((body != null || pgpEncrypted != null || axolotlEncrypted != null) && !isMucStatusMessage) {
Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query);
final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
+ if (serverMsgId == null) {
+ extractStanzaid(packet, isTypeGroupChat, conversation);
+ }
if (isTypeGroupChat) {
if (counterpart.getResourcepart().equals(conversation.getMucOptions().getActualNick())) {
status = Message.STATUS_SEND_RECEIVED;
isCarbon = true; //not really carbon but received from another resource
- if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status)) {
+ if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status, serverMsgId)) {
return;
} else if (remoteMsgId == null || Config.IGNORE_ID_REWRITE_IN_MUC) {
Message message = conversation.findSentMessageWithBody(packet.getBody());
@@ -437,21 +454,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
}
- if (serverMsgId == null) {
- final Jid by;
- final boolean safeToExtract;
- if (isTypeGroupChat) {
- by = conversation.getJid().toBareJid();
- safeToExtract = conversation.getMucOptions().hasFeature(Namespace.STANZA_IDS);
- } else {
- by = account.getJid().toBareJid();
- safeToExtract = account.getXmppConnection().getFeatures().stanzaIds();
- }
- if (safeToExtract) {
- serverMsgId = extractStanzaId(packet, by);
- }
- }
-
message.setCounterpart(counterpart);
message.setRemoteMsgId(remoteMsgId);
message.setServerMsgId(serverMsgId);
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index c4570d6c0..f2a6dc308 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -3282,12 +3282,15 @@ public class XmppConnectionService extends Service {
return null;
}
- public boolean markMessage(Conversation conversation, String uuid, int status) {
+ public boolean markMessage(Conversation conversation, String uuid, int status, String serverMessageId) {
if (uuid == null) {
return false;
} else {
Message message = conversation.findSentMessageWithUuid(uuid);
if (message != null) {
+ if (message.getServerMsgId() == null) {
+ message.setServerMsgId(serverMessageId);
+ }
markMessage(message, status);
return true;
} else {