diff options
author | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-03-19 16:16:40 +0100 |
---|---|---|
committer | Daniel Gultsch <daniel.gultsch@rwth-aachen.de> | 2014-03-19 16:16:40 +0100 |
commit | 6be2a08f19f07e9db5da3e644c8d62102fdd27e7 (patch) | |
tree | 88a319a2b46dd82ef5b5619605eda0cfe033f13e /src/eu/siacs/conversations/utils | |
parent | 389d4db311f22ceb787976a6c6130bb0260610bb (diff) |
otr messages are now ignored if conversations isnt 100% sure the message is ours
Diffstat (limited to 'src/eu/siacs/conversations/utils')
-rw-r--r-- | src/eu/siacs/conversations/utils/MessageParser.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java index d6f86900b..de8f4de88 100644 --- a/src/eu/siacs/conversations/utils/MessageParser.java +++ b/src/eu/siacs/conversations/utils/MessageParser.java @@ -31,18 +31,26 @@ public class MessageParser { } public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) { + boolean properlyAddressed = (packet.getTo().split("/").length == 2) || (account.countPresences() == 1); String[] fromParts = packet.getFrom().split("/"); Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false); String body = packet.getBody(); if (!conversation.hasValidOtrSession()) { - conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + if (properlyAddressed) { + conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + } else { + Log.d("xmppService",account.getJid()+": ignoring otr session with "+fromParts[0]); + return null; + } } else { String foreignPresence = conversation.getOtrSession().getSessionID().getUserID(); if (!foreignPresence.equals(fromParts[1])) { - Log.d(LOGTAG,"new otr during existing otr session requested. ending old one"); conversation.resetOtrSession(); - Log.d("xmppService","starting new one with "+fromParts[1]); - conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + if (properlyAddressed) { + conversation.startOtrSession(service.getApplicationContext(), fromParts[1]); + } else { + return null; + } } } try { |