sending warning to receiving client if that client doesn't support omemo.
fixes #1873
This commit is contained in:
parent
83adbb6052
commit
c06e2787c7
|
@ -122,7 +122,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFallbackMessage(SessionID arg0) {
|
public String getFallbackMessage(SessionID arg0) {
|
||||||
return "I would like to start a private (OTR encrypted) conversation but your client doesn’t seem to support that";
|
return MessageGenerator.OTR_FALLBACK_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
|
@ -20,6 +21,10 @@ import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
|
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
|
||||||
|
|
||||||
public class MessageGenerator extends AbstractGenerator {
|
public class MessageGenerator extends AbstractGenerator {
|
||||||
|
public static final String OTR_FALLBACK_MESSAGE = "I would like to start a private (OTR encrypted) conversation but your client doesn’t seem to support that";
|
||||||
|
private static final String OMEMO_FALLBACK_MESSAGE = "I sent you an OMEMO encrypted message but your client doesn’t seem to support that. Find more information on https://conversations.im/omemo";
|
||||||
|
private static final String PGP_FALLBACK_MESSAGE = "I sent you a PGP encrypted message but your client doesn’t seem to support that.";
|
||||||
|
|
||||||
public MessageGenerator(XmppConnectionService service) {
|
public MessageGenerator(XmppConnectionService service) {
|
||||||
super(service);
|
super(service);
|
||||||
}
|
}
|
||||||
|
@ -67,11 +72,18 @@ public class MessageGenerator extends AbstractGenerator {
|
||||||
if (axolotlMessage == null) {
|
if (axolotlMessage == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (!recipientSupportsOmemo(message)) {
|
||||||
|
packet.setBody(OMEMO_FALLBACK_MESSAGE);
|
||||||
|
}
|
||||||
packet.setAxolotlMessage(axolotlMessage.toElement());
|
packet.setAxolotlMessage(axolotlMessage.toElement());
|
||||||
packet.addChild("store", "urn:xmpp:hints");
|
packet.addChild("store", "urn:xmpp:hints");
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean recipientSupportsOmemo(Message message) {
|
||||||
|
return message.getContact().getPresences().allOrNonSupport(AxolotlService.PEP_DEVICE_LIST_NOTIFY);
|
||||||
|
}
|
||||||
|
|
||||||
public static void addMessageHints(MessagePacket packet) {
|
public static void addMessageHints(MessagePacket packet) {
|
||||||
packet.addChild("private", "urn:xmpp:carbons:2");
|
packet.addChild("private", "urn:xmpp:carbons:2");
|
||||||
packet.addChild("no-copy", "urn:xmpp:hints");
|
packet.addChild("no-copy", "urn:xmpp:hints");
|
||||||
|
@ -116,7 +128,7 @@ public class MessageGenerator extends AbstractGenerator {
|
||||||
|
|
||||||
public MessagePacket generatePgpChat(Message message) {
|
public MessagePacket generatePgpChat(Message message) {
|
||||||
MessagePacket packet = preparePacket(message);
|
MessagePacket packet = preparePacket(message);
|
||||||
packet.setBody("This is an XEP-0027 encrypted message");
|
packet.setBody(PGP_FALLBACK_MESSAGE);
|
||||||
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||||
packet.addChild("x", "jabber:x:encrypted").setContent(message.getEncryptedBody());
|
packet.addChild("x", "jabber:x:encrypted").setContent(message.getEncryptedBody());
|
||||||
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
|
|
Loading…
Reference in a new issue