mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-26 01:09:13 -05:00
refactor code that reads real jid from muc
This commit is contained in:
parent
4ba5472d0c
commit
982a20fef5
@ -391,7 +391,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||||||
status = Message.STATUS_RECEIVED;
|
status = Message.STATUS_RECEIVED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message message;
|
final Message message;
|
||||||
if (body != null && body.startsWith("?OTR") && Config.supportOtr()) {
|
if (body != null && body.startsWith("?OTR") && Config.supportOtr()) {
|
||||||
if (!isForwarded && !isTypeGroupChat && isProperlyAddressed && !conversationMultiMode) {
|
if (!isForwarded && !isTypeGroupChat && isProperlyAddressed && !conversationMultiMode) {
|
||||||
message = parseOtrChat(body, from, remoteMsgId, conversation);
|
message = parseOtrChat(body, from, remoteMsgId, conversation);
|
||||||
@ -407,7 +407,8 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||||||
} else if (axolotlEncrypted != null && Config.supportOmemo()) {
|
} else if (axolotlEncrypted != null && Config.supportOmemo()) {
|
||||||
Jid origin;
|
Jid origin;
|
||||||
if (conversationMultiMode) {
|
if (conversationMultiMode) {
|
||||||
origin = conversation.getMucOptions().getTrueCounterpart(counterpart);
|
final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
|
||||||
|
origin = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
|
||||||
if (origin == null) {
|
if (origin == null) {
|
||||||
Log.d(Config.LOGTAG,"axolotl message in non anonymous conference received");
|
Log.d(Config.LOGTAG,"axolotl message in non anonymous conference received");
|
||||||
return;
|
return;
|
||||||
@ -435,21 +436,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||||||
message.setOob(isOob);
|
message.setOob(isOob);
|
||||||
message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
|
message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
|
||||||
if (conversationMultiMode) {
|
if (conversationMultiMode) {
|
||||||
final Element item = mucUserElement == null ? null : mucUserElement.findChild("item");
|
final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
|
||||||
Jid trueCounterpart;
|
Jid trueCounterpart = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
|
||||||
if (Config.PARSE_REAL_JID_FROM_MUC_MAM && query != null && item != null) {
|
if (trueCounterpart != null && trueCounterpart.toBareJid().equals(account.getJid().toBareJid())) {
|
||||||
trueCounterpart = item.getAttributeAsJid("jid");
|
status = isTypeGroupChat ? Message.STATUS_SEND_RECEIVED : Message.STATUS_SEND;
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
trueCounterpart = conversation.getMucOptions().getTrueCounterpart(counterpart);
|
status = Message.STATUS_RECEIVED;
|
||||||
}
|
}
|
||||||
|
message.setStatus(status);
|
||||||
message.setTrueCounterpart(trueCounterpart);
|
message.setTrueCounterpart(trueCounterpart);
|
||||||
if (!isTypeGroupChat) {
|
if (!isTypeGroupChat) {
|
||||||
message.setType(Message.TYPE_PRIVATE);
|
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) {
|
private void sendMessageReceipts(Account account, MessagePacket packet) {
|
||||||
ArrayList<String> receiptsNamespaces = new ArrayList<>();
|
ArrayList<String> receiptsNamespaces = new ArrayList<>();
|
||||||
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
|
if (packet.hasChild("markable", "urn:xmpp:chat-markers:0")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user