don’t use xmpp or jabber as default muc nick

This commit is contained in:
Daniel Gultsch 2017-08-23 10:06:32 +02:00
parent 26f7702c39
commit 94e0c6b38c

View file

@ -3,6 +3,7 @@ package eu.siacs.conversations.entities;
import android.annotation.SuppressLint;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -20,6 +21,8 @@ import eu.siacs.conversations.xmpp.pep.Avatar;
@SuppressLint("DefaultLocale")
public class MucOptions {
private static List<String> LOCALPART_BLACKLIST = Arrays.asList("xmpp","jabber");
private boolean mAutoPushConfiguration = true;
public Account getAccount() {
@ -594,7 +597,7 @@ public class MucOptions {
}
}
public String getProposedNick() {
private String getProposedNick() {
if (conversation.getBookmark() != null
&& conversation.getBookmark().getNick() != null
&& !conversation.getBookmark().getNick().trim().isEmpty()) {
@ -602,7 +605,14 @@ public class MucOptions {
} else if (!conversation.getJid().isBareJid()) {
return conversation.getJid().getResourcepart();
} else {
return account.getUsername();
Jid jid = account.getJid();
if (LOCALPART_BLACKLIST.contains(jid.getLocalpart())) {
final String domain = jid.getDomainpart();
final int index = domain.lastIndexOf('.');
return index > 1 ? domain.substring(0,index) : domain;
} else {
return jid.getLocalpart();
}
}
}