aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-06-22 12:22:57 +0200
committerChristian Schneppe <christian@pix-art.de>2016-06-22 20:41:38 +0200
commit2ebf84bf8c5d9ba09a2b31f653a2689ddbc6d050 (patch)
tree707736bf67226cf3d803b334acfa2aa87dff9f4e /src
parent81b39728785916d64bf466b52df6fcc0e1b71ae5 (diff)
refactor code that reads real jid from muc
Diffstat (limited to 'src')
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index af71bdb09..3f5a8366c 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -391,7 +391,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
status = Message.STATUS_RECEIVED;
}
}
- Message message;
+ final Message message;
if (body != null && body.startsWith("?OTR") && Config.supportOtr()) {
if (!isForwarded && !isTypeGroupChat && isProperlyAddressed && !conversationMultiMode) {
message = parseOtrChat(body, from, remoteMsgId, conversation);
@@ -407,7 +407,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
} else if (axolotlEncrypted != null && Config.supportOmemo()) {
Jid origin;
if (conversationMultiMode) {
- origin = conversation.getMucOptions().getTrueCounterpart(counterpart);
+ final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
+ origin = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
if (origin == null) {
Log.d(Config.LOGTAG,"axolotl message in non anonymous conference received");
return;
@@ -435,21 +436,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
message.setOob(isOob);
message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
if (conversationMultiMode) {
- final Element item = mucUserElement == null ? null : mucUserElement.findChild("item");
- Jid trueCounterpart;
- if (Config.PARSE_REAL_JID_FROM_MUC_MAM && query != null && item != null) {
- trueCounterpart = item.getAttributeAsJid("jid");
- if (trueCounterpart != null) {
- if (trueCounterpart.toBareJid().equals(account.getJid().toBareJid())) {
- status = isTypeGroupChat ? Message.STATUS_SEND_RECEIVED : Message.STATUS_SEND;
- } else {
- status = Message.STATUS_RECEIVED;
- }
- message.setStatus(status);
- }
+ final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
+ Jid trueCounterpart = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
+ if (trueCounterpart != null && trueCounterpart.toBareJid().equals(account.getJid().toBareJid())) {
+ status = isTypeGroupChat ? Message.STATUS_SEND_RECEIVED : Message.STATUS_SEND;
} else {
- trueCounterpart = conversation.getMucOptions().getTrueCounterpart(counterpart);
+ status = Message.STATUS_RECEIVED;
}
+ message.setStatus(status);
message.setTrueCounterpart(trueCounterpart);
if (!isTypeGroupChat) {
message.setType(Message.TYPE_PRIVATE);
@@ -641,6 +635,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
}
+ private static Jid getTrueCounterpart(Element mucUserElement, Jid fallback) {
+ final Element item = mucUserElement == null ? null : mucUserElement.findChild("item");
+ Jid result = item == null ? null : item.getAttributeAsJid("jid");
+ return result != null && Config.PARSE_REAL_JID_FROM_MUC_MAM ? result : fallback;
+ }
+
private void sendMessageReceipts(Account account, MessagePacket packet) {
ArrayList<String> receiptsNamespaces = new ArrayList<>();
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {