From e6532e739a83a7d5c2804e1dd75e27d14a147d2c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 22 Jun 2018 20:25:50 +0200 Subject: [PATCH] do not include white listed domains in room list. fixes #3082 --- .../crypto/axolotl/AxolotlService.java | 2 +- .../conversations/entities/MucOptions.java | 24 +++++++++---------- .../services/XmppConnectionService.java | 5 ++-- .../ui/ConferenceDetailsActivity.java | 2 +- src/main/res/values/strings.xml | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java index 5637a2889..3d23c65d1 100644 --- a/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java +++ b/src/main/java/eu/siacs/conversations/crypto/axolotl/AxolotlService.java @@ -868,7 +868,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded { jids = new ArrayList<>(); jids.add(conversation.getJid().asBareJid()); } else { - jids = conversation.getMucOptions().getMembers(); + jids = conversation.getMucOptions().getMembers(false); } return jids; } diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index a080a488c..51333437c 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -306,6 +306,10 @@ public class MucOptions { } + public boolean isDomain() { + return realJid != null && realJid.getLocal() == null && role == Role.NONE; + } + @Override public int hashCode() { int result = role != null ? role.hashCode() : 0; @@ -610,17 +614,13 @@ public class MucOptions { public ArrayList getUsers(boolean includeOffline) { synchronized (users) { - if (includeOffline) { - return new ArrayList<>(users); - } else { - ArrayList onlineUsers = new ArrayList<>(); - for (User user : users) { - if (user.getRole().ranks(Role.PARTICIPANT)) { - onlineUsers.add(user); + ArrayList users = new ArrayList<>(); + for (User user : this.users) { + if (!user.isDomain() && (includeOffline || user.getRole().ranks(Role.PARTICIPANT))) { + users.add(user); } } - return onlineUsers; - } + return users; } } @@ -645,7 +645,7 @@ public class MucOptions { jids.add(account.getJid().asBareJid()); synchronized (users) { for (User user : users) { - if (user.getRealJid() == null || jids.add(user.getRealJid())) { + if (user.getRealJid() == null || (user.getRealJid().getLocal() != null && jids.add(user.getRealJid()))) { subset.add(user); } if (subset.size() >= max) { @@ -834,11 +834,11 @@ public class MucOptions { return this.conversation; } - public List getMembers() { + public List getMembers(final boolean includeDomains) { ArrayList members = new ArrayList<>(); synchronized (users) { for (User user : users) { - if (user.affiliation.ranks(Affiliation.MEMBER) && user.realJid != null) { + if (user.affiliation.ranks(Affiliation.MEMBER) && user.realJid != null && (!user.isDomain() || includeDomains)) { members.add(user.realJid); } } diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 68ab0fa51..34ebf6cda 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2220,13 +2220,13 @@ public class XmppConnectionService extends Service { } ++i; if (i >= affiliations.length) { - List members = conversation.getMucOptions().getMembers(); + List members = conversation.getMucOptions().getMembers(true); if (success) { List cryptoTargets = conversation.getAcceptedCryptoTargets(); boolean changed = false; for (ListIterator iterator = cryptoTargets.listIterator(); iterator.hasNext(); ) { Jid jid = iterator.next(); - if (!members.contains(jid)) { + if (!members.contains(jid) && !members.contains(Jid.ofDomain(jid.getDomain()))) { iterator.remove(); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName()); changed = true; @@ -2237,7 +2237,6 @@ public class XmppConnectionService extends Service { updateConversation(conversation); } } - Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retrieved members for " + conversation.getJid().asBareJid() + ": " + conversation.getMucOptions().getMembers()); getAvatarService().clear(conversation); updateMucRosterUi(); updateConversationUi(); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 1617fbe62..b6c2900ff 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -244,7 +244,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers setSupportActionBar((Toolbar) binding.toolbar); configureActionBar(getSupportActionBar()); this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(), - R.string.nickname_for_this_group_chat, + R.string.nickname, value -> { if (xmppConnectionService.renameInMuc(mConversation, value, renameCallback)) { return null; diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 9fa7398fa..1376e0c25 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -720,5 +720,5 @@ Host does not support group chat avatars Only the owner can change group chat avatar Contact name - Nickname for this group chat + Nickname