From 94e0c6b38c10e98afea6dcfcf150ed274802b0e6 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Aug 2017 10:06:32 +0200 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20use=20xmpp=20or=20jabber=20as?= =?UTF-8?q?=20default=20muc=20nick?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../siacs/conversations/entities/MucOptions.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 6e98db605..32faced8f 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -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 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(); + } } }