Commit 53e6ae31 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed problem where a roster item was assumed to exist (implicitly) when using...

Fixed problem where a roster item was assumed to exist (implicitly) when using public shared groups. JM-647

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3786 b35dd754-fafc-0310-a699-88a17e54d16e
parent 69349bb7
......@@ -82,7 +82,7 @@ public class Roster implements Cacheable {
// Get the shared groups of this user
Collection<Group> sharedGroups = rosterManager.getSharedGroups(username);
Collection<Group> userGroups = GroupManager.getInstance().getGroups(getUserJID());;
Collection<Group> userGroups = GroupManager.getInstance().getGroups(getUserJID());
// Add RosterItems that belong to the personal roster
rosterItemProvider = RosterItemProvider.getInstance();
......@@ -217,8 +217,11 @@ public class Roster implements Cacheable {
// Check if there is a public shared group. That means that anyone can see this user.
for (Group group : userGroups) {
if (rosterManager.isPulicSharedGroup(group)) {
return new RosterItem(user, RosterItem.SUB_FROM, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, "", null);
// Only local users may see public shared groups
if (server.isLocal(user)) {
return new RosterItem(user, RosterItem.SUB_FROM, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, "", null);
}
}
else if (rosterManager.isSharedGroup(group)) {
// This is a shared group that can be seen only by group members or
......@@ -227,11 +230,8 @@ public class Roster implements Cacheable {
}
}
if (!sharedGroups.isEmpty()) {
// Check if any group of contact may see a shared group of this user
// Check if any group of the contact may see a shared group of this user
Collection<Group> contactGroups = GroupManager.getInstance().getGroups(user);
if (contactGroups == null) {
return null;
}
for (Group sharedGroup : sharedGroups) {
if (rosterManager.isSharedGroupVisible(sharedGroup, contactGroups)) {
return new RosterItem(user, RosterItem.SUB_FROM, RosterItem.ASK_NONE,
......@@ -342,7 +342,7 @@ public class Roster implements Cacheable {
if (item.isShared() && item.getID() == 0) {
// Do nothing if item is only shared and it is using the default user name
if (item.isOnlyShared()) {
String defaultContactName = null;
String defaultContactName;
try {
defaultContactName = UserNameManager.getUserName(item.getJid());
}
......@@ -942,7 +942,7 @@ public class Roster implements Cacheable {
// Update the subscription of the item **based on the item groups**
if (item.isOnlyShared()) {
Collection<Group> userGroups =
userGroups = GroupManager.getInstance().getGroups(getUserJID());
GroupManager.getInstance().getGroups(getUserJID());
// Set subscription type to BOTH if the roster user belongs to a shared group
// that is mutually visible with a shared group of the new roster item
if (rosterManager
......@@ -985,7 +985,7 @@ public class Roster implements Cacheable {
if (userJID.equals(user)) {
continue;
}
RosterItem item = null;
RosterItem item;
try {
// Get the RosterItem for the *local* user to add
item = getRosterItem(user);
......
......@@ -372,12 +372,15 @@ public class RosterManager extends BasicModule implements GroupEventListener {
* @return true if any of the specified groups can see the shared group.
*/
public boolean isSharedGroupVisible(Group sharedGroup, Collection<Group> groups) {
if (groups.isEmpty()) {
return false;
}
Map<String, String> properties = sharedGroup.getProperties();
String showInRoster = properties.get("sharedRoster.showInRoster");
if ("everybody".equals(showInRoster)) {
return true;
}
if ("onlyGroup".equals(showInRoster) && !groups.isEmpty()) {
if ("onlyGroup".equals(showInRoster)) {
Collection<String> groupNames = new ArrayList<String>(groups.size());
for (Group group : groups) {
groupNames.add(group.getName());
......
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