Commit fec7ed78 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

1) Optimized by removing db queries. JM-592

2) Fixed shared group problem by not creating roster items when not required. JM-591

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3536 b35dd754-fafc-0310-a699-88a17e54d16e
parent b43eb3e3
......@@ -294,6 +294,11 @@ public class Roster implements Cacheable {
}
// If the item only had shared groups before this update then make it persistent
if (item.isShared() && item.getID() == 0) {
// Do nothing if item is only shared and it is using the default user name
String defaultContactName = UserNameManager.getUserName(item.getJid());
if (item.isOnlyShared() && defaultContactName.equals(item.getNickname())) {
return;
}
try {
rosterItemProvider.createItem(username, item);
}
......@@ -831,7 +836,7 @@ public class Roster implements Cacheable {
}
}
void deleteSharedUser(JID deletedUser, Collection<Group> groups, Group deletedGroup) {
void deleteSharedUser(JID deletedUser, Group deletedGroup) {
try {
// Get the RosterItem for the *local* user to remove
RosterItem item = getRosterItem(deletedUser);
......@@ -852,6 +857,8 @@ public class Roster implements Cacheable {
rosterManager.isGroupPublic(deletedGroup))) {
item.removeSharedGroup(deletedGroup);
}
// Get the groups of the deleted user
Collection<Group> groups = GroupManager.getInstance().getGroups(deletedUser);
// Remove all invalid shared groups from the roster item
for (Group group : groups) {
if (!rosterManager.isGroupVisible(group, getUserJID())) {
......
......@@ -526,8 +526,7 @@ public class RosterManager extends BasicModule implements GroupEventListener {
}
// Update the roster of the newly deleted group user.
if (deletedUserRoster != null) {
Collection<Group> groups = GroupManager.getInstance().getGroups(userToUpdate);
deletedUserRoster.deleteSharedUser(userToUpdate, groups, group);
deletedUserRoster.deleteSharedUser(userToUpdate, group);
}
if (!server.isLocal(deletedUser)) {
// Unsusbcribe from the presence of the remote user. This is only necessary for
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment