aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/parser/MessageParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/parser/MessageParser.java')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index ed12d6473..8f5b1b851 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -23,6 +23,7 @@ import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.crypto.OtrService;
import de.pixart.messenger.crypto.axolotl.AxolotlService;
+import de.pixart.messenger.crypto.axolotl.BrokenSessionException;
import de.pixart.messenger.crypto.axolotl.NotEncryptedForThisDeviceException;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage;
import de.pixart.messenger.entities.Account;
@@ -200,7 +201,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
}
- private Message parseAxolotlChat(Element axolotlMessage, Jid from, Conversation conversation, int status, boolean postpone) {
+ private Message parseAxolotlChat(Element axolotlMessage, Jid from, Conversation conversation, int status, boolean checkedForDuplicates, boolean postpone) {
final AxolotlService service = conversation.getAccount().getAxolotlService();
final XmppAxolotlMessage xmppAxolotlMessage;
try {
@@ -213,6 +214,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage;
try {
plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage, postpone);
+ } catch (BrokenSessionException e) {
+ if (checkedForDuplicates) {
+ service.reportBrokenSessionException(e, postpone);
+ return new Message(conversation, "", Message.ENCRYPTION_AXOLOTL_FAILED, status);
+ } else {
+ Log.d(Config.LOGTAG, "ignoring broken session exception because checkForDuplicase failed");
+ return null;
+ }
} catch (NotEncryptedForThisDeviceException e) {
return new Message(conversation, "", Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE, status);
}
@@ -531,12 +540,15 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
fallbacksBySourceId = Collections.emptySet();
origin = from;
}
+
+ final boolean checkedForDuplicates = serverMsgId != null && remoteMsgId != null && !conversation.possibleDuplicate(serverMsgId, remoteMsgId);
+
if (origin != null) {
- message = parseAxolotlChat(axolotlEncrypted, origin, conversation, status, query != null);
+ message = parseAxolotlChat(axolotlEncrypted, origin, conversation, status, checkedForDuplicates,query != null);
} else {
Message trial = null;
for (Jid fallback : fallbacksBySourceId) {
- trial = parseAxolotlChat(axolotlEncrypted, fallback, conversation, status, query != null);
+ trial = parseAxolotlChat(axolotlEncrypted, fallback, conversation, status, checkedForDuplicates && fallbacksBySourceId.size() == 1, query != null);
if (trial != null) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": decoded muc message using fallback");
origin = fallback;
@@ -713,7 +725,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
notify = conversation.getAccount().getPgpDecryptionService().decrypt(message, notify);
- } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE) {
+ } else if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL_NOT_FOR_THIS_DEVICE || message.getEncryption() == Message.ENCRYPTION_AXOLOTL_FAILED) {
notify = false;
}