Commit 906a4623 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Subscription status is now calculated correctly for existing roster items when...

Subscription status is now calculated correctly for existing roster items when a new member is added to a shared group. JM-451

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@3029 b35dd754-fafc-0310-a699-88a17e54d16e
parent af3ab023
......@@ -603,8 +603,14 @@ public class Roster implements Cacheable {
")");
}
}
// If an item already exists then take note of the old subscription status
RosterItem.SubType prevSubscription = null;
if (!newItem) {
prevSubscription = item.getSubStatus();
}
// Update the subscription of the item **based on the item groups**
if (newItem || item.isOnlyShared()) {
Collection<Group> userGroups = null;
Collection<Group> sharedGroups = new ArrayList<Group>();
try {
......@@ -631,7 +637,6 @@ public class Roster implements Cacheable {
}
catch (UserNotFoundException e) {
}
}
// Add the shared group to the list of shared groups
if (item.getSubStatus() != RosterItem.SUB_FROM) {
......@@ -640,6 +645,20 @@ public class Roster implements Cacheable {
else {
item.addInvisibleSharedGroup(group);
}
// If the item already exists then check if the subscription status should be
// changed to BOTH based on the old and new subscription status
if (prevSubscription != null) {
if (prevSubscription == RosterItem.SUB_TO &&
item.getSubStatus() == RosterItem.SUB_FROM) {
item.setSubStatus(RosterItem.SUB_BOTH);
}
else if (prevSubscription == RosterItem.SUB_FROM &&
item.getSubStatus() == RosterItem.SUB_TO) {
item.setSubStatus(RosterItem.SUB_BOTH);
}
}
// Brodcast to all the user resources of the updated roster item
broadcast(item, true);
// Probe the presence of the new group user
......@@ -682,7 +701,6 @@ public class Roster implements Cacheable {
}
}
// Update the subscription of the item **based on the item groups**
if (newItem || item.isOnlyShared()) {
Collection<Group> userGroups = null;
try {
User rosterUser = UserManager.getInstance().getUser(getUsername());
......@@ -712,6 +730,12 @@ public class Roster implements Cacheable {
}
}
else {
// If an item already exists then take note of the old subscription status
RosterItem.SubType prevSubscription = null;
if (!newItem) {
prevSubscription = item.getSubStatus();
}
// Assume by default that the contact has subscribed from the presence of
// this user
item.setSubStatus(RosterItem.SUB_FROM);
......@@ -726,11 +750,23 @@ public class Roster implements Cacheable {
if (item.getSubStatus() == RosterItem.SUB_FROM) {
item.addInvisibleSharedGroup(addedGroup);
}
// If the item already exists then check if the subscription status should be
// changed to BOTH based on the old and new subscription status
if (prevSubscription != null) {
if (prevSubscription == RosterItem.SUB_TO &&
item.getSubStatus() == RosterItem.SUB_FROM) {
item.setSubStatus(RosterItem.SUB_BOTH);
}
else if (prevSubscription == RosterItem.SUB_FROM &&
item.getSubStatus() == RosterItem.SUB_TO) {
item.setSubStatus(RosterItem.SUB_BOTH);
}
}
catch (UserNotFoundException e) {
}
}
catch (UserNotFoundException e) {
}
// Brodcast to all the user resources of the updated roster item
broadcast(item, true);
// Probe the presence of the new group user
......
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