do not include white listed domains in room list. fixes #3082

This commit is contained in:
Daniel Gultsch 2018-06-22 20:25:50 +02:00
parent 1fc432af53
commit e6532e739a
5 changed files with 17 additions and 18 deletions

View file

@ -868,7 +868,7 @@ public class AxolotlService implements OnAdvancedStreamFeaturesLoaded {
jids = new ArrayList<>(); jids = new ArrayList<>();
jids.add(conversation.getJid().asBareJid()); jids.add(conversation.getJid().asBareJid());
} else { } else {
jids = conversation.getMucOptions().getMembers(); jids = conversation.getMucOptions().getMembers(false);
} }
return jids; return jids;
} }

View file

@ -306,6 +306,10 @@ public class MucOptions {
} }
public boolean isDomain() {
return realJid != null && realJid.getLocal() == null && role == Role.NONE;
}
@Override @Override
public int hashCode() { public int hashCode() {
int result = role != null ? role.hashCode() : 0; int result = role != null ? role.hashCode() : 0;
@ -610,17 +614,13 @@ public class MucOptions {
public ArrayList<User> getUsers(boolean includeOffline) { public ArrayList<User> getUsers(boolean includeOffline) {
synchronized (users) { synchronized (users) {
if (includeOffline) { ArrayList<User> users = new ArrayList<>();
return new ArrayList<>(users); for (User user : this.users) {
} else { if (!user.isDomain() && (includeOffline || user.getRole().ranks(Role.PARTICIPANT))) {
ArrayList<User> onlineUsers = new ArrayList<>(); users.add(user);
for (User user : users) {
if (user.getRole().ranks(Role.PARTICIPANT)) {
onlineUsers.add(user);
} }
} }
return onlineUsers; return users;
}
} }
} }
@ -645,7 +645,7 @@ public class MucOptions {
jids.add(account.getJid().asBareJid()); jids.add(account.getJid().asBareJid());
synchronized (users) { synchronized (users) {
for (User user : 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); subset.add(user);
} }
if (subset.size() >= max) { if (subset.size() >= max) {
@ -834,11 +834,11 @@ public class MucOptions {
return this.conversation; return this.conversation;
} }
public List<Jid> getMembers() { public List<Jid> getMembers(final boolean includeDomains) {
ArrayList<Jid> members = new ArrayList<>(); ArrayList<Jid> members = new ArrayList<>();
synchronized (users) { synchronized (users) {
for (User user : 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); members.add(user.realJid);
} }
} }

View file

@ -2220,13 +2220,13 @@ public class XmppConnectionService extends Service {
} }
++i; ++i;
if (i >= affiliations.length) { if (i >= affiliations.length) {
List<Jid> members = conversation.getMucOptions().getMembers(); List<Jid> members = conversation.getMucOptions().getMembers(true);
if (success) { if (success) {
List<Jid> cryptoTargets = conversation.getAcceptedCryptoTargets(); List<Jid> cryptoTargets = conversation.getAcceptedCryptoTargets();
boolean changed = false; boolean changed = false;
for (ListIterator<Jid> iterator = cryptoTargets.listIterator(); iterator.hasNext(); ) { for (ListIterator<Jid> iterator = cryptoTargets.listIterator(); iterator.hasNext(); ) {
Jid jid = iterator.next(); Jid jid = iterator.next();
if (!members.contains(jid)) { if (!members.contains(jid) && !members.contains(Jid.ofDomain(jid.getDomain()))) {
iterator.remove(); iterator.remove();
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName()); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName());
changed = true; changed = true;
@ -2237,7 +2237,6 @@ public class XmppConnectionService extends Service {
updateConversation(conversation); updateConversation(conversation);
} }
} }
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": retrieved members for " + conversation.getJid().asBareJid() + ": " + conversation.getMucOptions().getMembers());
getAvatarService().clear(conversation); getAvatarService().clear(conversation);
updateMucRosterUi(); updateMucRosterUi();
updateConversationUi(); updateConversationUi();

View file

@ -244,7 +244,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
setSupportActionBar((Toolbar) binding.toolbar); setSupportActionBar((Toolbar) binding.toolbar);
configureActionBar(getSupportActionBar()); configureActionBar(getSupportActionBar());
this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(), this.binding.editNickButton.setOnClickListener(v -> quickEdit(mConversation.getMucOptions().getActualNick(),
R.string.nickname_for_this_group_chat, R.string.nickname,
value -> { value -> {
if (xmppConnectionService.renameInMuc(mConversation, value, renameCallback)) { if (xmppConnectionService.renameInMuc(mConversation, value, renameCallback)) {
return null; return null;

View file

@ -720,5 +720,5 @@
<string name="host_does_not_support_group_chat_avatars">Host does not support group chat avatars</string> <string name="host_does_not_support_group_chat_avatars">Host does not support group chat avatars</string>
<string name="only_the_owner_can_change_group_chat_avatar">Only the owner can change group chat avatar</string> <string name="only_the_owner_can_change_group_chat_avatar">Only the owner can change group chat avatar</string>
<string name="contact_name">Contact name</string> <string name="contact_name">Contact name</string>
<string name="nickname_for_this_group_chat">Nickname for this group chat</string> <string name="nickname">Nickname</string>
</resources> </resources>