rework quicksy domain checks

This commit is contained in:
Daniel Gultsch 2020-06-13 08:26:32 +02:00
parent 56ea9647cd
commit 0dba9f560c
6 changed files with 10 additions and 5 deletions

View File

@ -41,7 +41,7 @@ public final class Config {
public static final String DOMAIN_LOCK = null; //only allow account creation for this domain public static final String DOMAIN_LOCK = null; //only allow account creation for this domain
public static final String MAGIC_CREATE_DOMAIN = "conversations.im"; public static final String MAGIC_CREATE_DOMAIN = "conversations.im";
public static final String QUICKSY_DOMAIN = "quicksy.im"; public static final Jid QUICKSY_DOMAIN = Jid.of("quicksy.im");
public static final String CHANNEL_DISCOVERY = "https://search.jabber.network"; public static final String CHANNEL_DISCOVERY = "https://search.jabber.network";

View File

@ -134,7 +134,7 @@ public class Contact implements ListItem, Blockable {
return this.systemName; return this.systemName;
} else if (!TextUtils.isEmpty(this.serverName)) { } else if (!TextUtils.isEmpty(this.serverName)) {
return this.serverName; return this.serverName;
} else if (!TextUtils.isEmpty(this.presenceName) && ((QuickConversationsService.isQuicksy() && Config.QUICKSY_DOMAIN.equals(jid.getDomain().toEscapedString())) ||mutualPresenceSubscription())) { } else if (!TextUtils.isEmpty(this.presenceName) && ((QuickConversationsService.isQuicksy() && JidHelper.isQuicksyDomain(jid.getDomain())) ||mutualPresenceSubscription())) {
return this.presenceName; return this.presenceName;
} else if (jid.getLocal() != null) { } else if (jid.getLocal() != null) {
return JidHelper.localPartOrFallback(jid); return JidHelper.localPartOrFallback(jid);

View File

@ -1006,7 +1006,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
&& !contact.isOwnServer() && !contact.isOwnServer()
&& !contact.showInContactList() && !contact.showInContactList()
&& !contact.isSelf() && !contact.isSelf()
&& !(Config.QUICKSY_DOMAIN != null && Config.QUICKSY_DOMAIN.equals(contact.getJid().toEscapedString())) && !JidHelper.isQuicksyDomain(contact.getJid())
&& sentMessagesCount() == 0; && sentMessagesCount() == 0;
} }

View File

@ -4146,7 +4146,7 @@ public class XmppConnectionService extends Service {
} }
} }
if (Config.QUICKSY_DOMAIN != null) { if (Config.QUICKSY_DOMAIN != null) {
hosts.remove(Config.QUICKSY_DOMAIN); //we only want to show this when we type a e164 number hosts.remove(Config.QUICKSY_DOMAIN.toEscapedString()); //we only want to show this when we type a e164 number
} }
if (Config.DOMAIN_LOCK != null) { if (Config.DOMAIN_LOCK != null) {
hosts.add(Config.DOMAIN_LOCK); hosts.add(Config.DOMAIN_LOCK);

View File

@ -27,7 +27,7 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
if (split.length == 1) { if (split.length == 1) {
final String local = split[0].toLowerCase(Locale.ENGLISH); final String local = split[0].toLowerCase(Locale.ENGLISH);
if (Config.QUICKSY_DOMAIN != null && E164_PATTERN.matcher(local).matches()) { if (Config.QUICKSY_DOMAIN != null && E164_PATTERN.matcher(local).matches()) {
suggestions.add(local + '@' + Config.QUICKSY_DOMAIN); suggestions.add(local + '@' + Config.QUICKSY_DOMAIN.toEscapedString());
} else { } else {
for (String domain : domains) { for (String domain : domains) {
suggestions.add(local + '@' + domain); suggestions.add(local + '@' + domain);

View File

@ -34,6 +34,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.xmpp.InvalidJid; import eu.siacs.conversations.xmpp.InvalidJid;
import eu.siacs.conversations.xmpp.Jid; import eu.siacs.conversations.xmpp.Jid;
@ -59,4 +60,8 @@ public class JidHelper {
} }
} }
public static boolean isQuicksyDomain(final Jid jid) {
return Config.QUICKSY_DOMAIN != null && Config.QUICKSY_DOMAIN.equals(jid.getDomain());
}
} }