don't create secret chat for OTR messages without resource

This commit is contained in:
kosyak 2024-10-14 22:14:22 +02:00
parent a66fa08be4
commit b18f042b8b

View file

@ -597,8 +597,9 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
final boolean conversationIsProbablyMuc = isTypeGroupChat || mucUserElement != null || account.getXmppConnection().getMucServersWithholdAccount().contains(counterpart.getDomain().toEscapedString());
final boolean isOTR = body != null && body.content.startsWith("?OTR") && Config.supportOtr();
final boolean correctOTR = !isForwarded && !isTypeGroupChat && isProperlyAddressed;
if ((conversationIsProbablyMuc && !isTypeGroupChat) || (!Strings.isNullOrEmpty(counterpart.getResource()) && isOTR)) {
if ((conversationIsProbablyMuc && !isTypeGroupChat) || (!Strings.isNullOrEmpty(counterpart.getResource()) && isOTR && correctOTR)) {
nextCounterpart = counterpart;
}
@ -663,17 +664,14 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
final Message message;
if (isOTR) {
if (!isForwarded && !isTypeGroupChat && isProperlyAddressed && !conversationMultiMode) {
if (correctOTR && !conversationMultiMode) {
message = parseOtrChat(body.content, from, remoteMsgId, conversation);
if (message == null) {
return;
}
} else {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": ignoring OTR message from " + from + " isForwarded=" + Boolean.toString(isForwarded) + ", isProperlyAddressed=" + Boolean.valueOf(isProperlyAddressed));
message = new Message(conversation, body.content, Message.ENCRYPTION_NONE, status);
if (body.count > 1) {
message.setBodyLanguage(body.language);
}
message = null;
}
} else if (pgpEncrypted != null && Config.supportOpenPgp()) {
message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);