aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-13 22:15:05 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-13 22:15:05 +0200
commit0f7f4bf5ed4bc8d07c333daf2c5c519dd0c7fdc9 (patch)
treeb3179f920caf10fd326014a976b088de82581e52 /src
parented91b6b648116690ffcab8b0a0569c4e769ad519 (diff)
add ruleset to disable omemo-by-default for certain providers
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/Config.java12
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java13
2 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/Config.java b/src/main/java/de/pixart/messenger/Config.java
index 7c676122b..4e1c86372 100644
--- a/src/main/java/de/pixart/messenger/Config.java
+++ b/src/main/java/de/pixart/messenger/Config.java
@@ -2,6 +2,9 @@ package de.pixart.messenger;
import android.graphics.Bitmap;
+import java.util.Collections;
+import java.util.List;
+
import de.pixart.messenger.xmpp.chatstate.ChatState;
import rocks.xmpp.addr.Jid;
@@ -169,6 +172,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() {
}
}
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 3769cedf6..266e06e10 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -753,10 +753,9 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
if (!Config.supportOmemo() && !Config.supportOpenPgp() && !Config.supportOtr()) {
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;
@@ -772,6 +771,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));
}