add ruleset to disable omemo-by-default for certain providers
This commit is contained in:
parent
536149723e
commit
06f8d8c5d6
|
@ -2,6 +2,10 @@ package eu.siacs.conversations;
|
|||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import eu.siacs.conversations.xmpp.chatstate.ChatState;
|
||||
import rocks.xmpp.addr.Jid;
|
||||
|
||||
|
@ -145,6 +149,15 @@ public final class Config {
|
|||
"_MD5",
|
||||
};
|
||||
|
||||
public static class OMEMO_EXCEPTIONS {
|
||||
//if the own account matches one of the following domains OMEMO won’t be turned on automatically
|
||||
public static final List<String> ACCOUNT_DOMAINS = Collections.singletonList("s.ms");
|
||||
|
||||
//if the contacts domain matches one of the following domains OMEMO won’t be turned on automatically
|
||||
//can be used for well known, widely used gateways
|
||||
public static final List<String> CONTACT_DOMAINS = Collections.singletonList("cheogram.com");
|
||||
}
|
||||
|
||||
private Config() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -596,10 +596,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|||
if (!Config.supportOmemo() && !Config.supportOpenPgp()) {
|
||||
return Message.ENCRYPTION_NONE;
|
||||
}
|
||||
AxolotlService axolotlService = account.getAxolotlService();
|
||||
if (contactJid.asBareJid().equals(Config.BUG_REPORTS)) {
|
||||
defaultEncryption = Message.ENCRYPTION_NONE;
|
||||
} else if (axolotlService != null && axolotlService.isConversationAxolotlCapable(this)) {
|
||||
} else if (suitableForOmemoByDefault(this)) {
|
||||
defaultEncryption = Message.ENCRYPTION_AXOLOTL;
|
||||
} else {
|
||||
defaultEncryption = Message.ENCRYPTION_NONE;
|
||||
|
@ -612,6 +611,16 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
|
|||
}
|
||||
}
|
||||
|
||||
private static boolean suitableForOmemoByDefault(final Conversation conversation) {
|
||||
final String contact = conversation.getJid().getDomain();
|
||||
final String account = conversation.getAccount().getServer();
|
||||
if (Config.OMEMO_EXCEPTIONS.CONTACT_DOMAINS.contains(contact) || Config.OMEMO_EXCEPTIONS.ACCOUNT_DOMAINS.contains(account)) {
|
||||
return false;
|
||||
}
|
||||
final AxolotlService axolotlService = conversation.getAccount().getAxolotlService();
|
||||
return axolotlService != null && axolotlService.isConversationAxolotlCapable(conversation);
|
||||
}
|
||||
|
||||
public void setNextEncryption(int encryption) {
|
||||
this.setAttribute(ATTRIBUTE_NEXT_ENCRYPTION, String.valueOf(encryption));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue