mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 12:42:16 -05:00
better handle the case when same user is joined with multiple nicks in the same room
This commit is contained in:
parent
33e6d8a1ce
commit
9e7a54849d
@ -3,7 +3,6 @@ package eu.siacs.conversations.entities;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -395,10 +394,18 @@ public class MucOptions {
|
|||||||
if (user != null) {
|
if (user != null) {
|
||||||
synchronized (users) {
|
synchronized (users) {
|
||||||
users.remove(user);
|
users.remove(user);
|
||||||
if (membersOnly() &&
|
boolean realJidInMuc = false;
|
||||||
nonanonymous() &&
|
for (User u : users) {
|
||||||
user.affiliation.ranks(Affiliation.MEMBER) &&
|
if (user.realJid != null && user.realJid.equals(u.realJid)) {
|
||||||
user.realJid != null) {
|
realJidInMuc = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (membersOnly()
|
||||||
|
&& nonanonymous()
|
||||||
|
&& user.affiliation.ranks(Affiliation.MEMBER)
|
||||||
|
&& user.realJid != null
|
||||||
|
&& !realJidInMuc) {
|
||||||
user.role = Role.NONE;
|
user.role = Role.NONE;
|
||||||
user.avatar = null;
|
user.avatar = null;
|
||||||
user.fullJid = null;
|
user.fullJid = null;
|
||||||
@ -508,8 +515,19 @@ public class MucOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getUsers(int max) {
|
public List<User> getUsers(int max) {
|
||||||
ArrayList<User> users = getUsers();
|
ArrayList<User> subset = new ArrayList<>();
|
||||||
return users.subList(0, Math.min(max, users.size()));
|
HashSet<Jid> jids = new HashSet<>();
|
||||||
|
synchronized (users) {
|
||||||
|
for(User user : users) {
|
||||||
|
if (user.getRealJid() == null || jids.add(user.getRealJid())) {
|
||||||
|
subset.add(user);
|
||||||
|
}
|
||||||
|
if (subset.size() >= max) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return subset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUserCount() {
|
public int getUserCount() {
|
||||||
|
@ -172,7 +172,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
|
|||||||
if (bitmap != null || cachedOnly) {
|
if (bitmap != null || cachedOnly) {
|
||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
final List<MucOptions.User> users = mucOptions.getUsers();
|
final List<MucOptions.User> users = mucOptions.getUsers(5);
|
||||||
int count = users.size();
|
int count = users.size();
|
||||||
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
|
Loading…
Reference in New Issue
Block a user