aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-11-29 21:43:29 +0100
committerChristian Schneppe <christian@pix-art.de>2016-11-29 21:43:29 +0100
commit230c9dbead61f707e975a14a63680caf353c9993 (patch)
tree5860b71a47a9818780a06ec473160e67abc06d5a /src
parent489ea5d38e68133c4d7acd106cb869ac3701c6d4 (diff)
better handle the case when same user is joined with multiple nicks in the same room
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java31
-rw-r--r--src/main/java/de/pixart/messenger/services/AvatarService.java2
2 files changed, 26 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index a95debd89..8ec3cbfd4 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -394,10 +394,18 @@ public class MucOptions {
if (user != null) {
synchronized (users) {
users.remove(user);
- if (membersOnly() &&
- nonanonymous() &&
- user.affiliation.ranks(Affiliation.MEMBER) &&
- user.realJid != null) {
+ boolean realJidInMuc = false;
+ for (User u : users) {
+ if (user.realJid != null && user.realJid.equals(u.realJid)) {
+ realJidInMuc = true;
+ break;
+ }
+ }
+ if (membersOnly()
+ && nonanonymous()
+ && user.affiliation.ranks(Affiliation.MEMBER)
+ && user.realJid != null
+ && !realJidInMuc) {
user.role = Role.NONE;
user.avatar = null;
user.fullJid = null;
@@ -507,8 +515,19 @@ public class MucOptions {
}
public List<User> getUsers(int max) {
- ArrayList<User> users = getUsers();
- return users.subList(0, Math.min(max, users.size()));
+ ArrayList<User> subset = new ArrayList<>();
+ 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() {
diff --git a/src/main/java/de/pixart/messenger/services/AvatarService.java b/src/main/java/de/pixart/messenger/services/AvatarService.java
index 234bb9c04..9ba9a1ba0 100644
--- a/src/main/java/de/pixart/messenger/services/AvatarService.java
+++ b/src/main/java/de/pixart/messenger/services/AvatarService.java
@@ -172,7 +172,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
if (bitmap != null || cachedOnly) {
return bitmap;
}
- final List<MucOptions.User> users = mucOptions.getUsers();
+ final List<MucOptions.User> users = mucOptions.getUsers(5);
int count = users.size();
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);