Implemented subscription visibility. If a subscription is not visible

to a contact, do not accept, offer, or send messages belonging to that
group to or from that contact, and do not list that group in
subscription updates sent to that contact.
This commit is contained in:
akwizgran
2011-07-27 16:43:19 +01:00
parent 4311b1a224
commit e93fbe0b20
8 changed files with 398 additions and 36 deletions

View File

@@ -693,8 +693,8 @@ public abstract class DatabaseComponentTest extends TestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
// Get the local subscriptions
oneOf(database).getSubscriptions(txn);
// Get the visible subscriptions
oneOf(database).getVisibleSubscriptions(txn, contactId);
will(returnValue(Collections.singletonList(group)));
// Add the subscriptions to the writer
oneOf(subscriptionWriter).writeSubscriptions(
@@ -776,10 +776,11 @@ public abstract class DatabaseComponentTest extends TestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
// Only store messages belonging to subscribed groups
// Only store messages belonging to visible, subscribed groups
oneOf(batch).getMessages();
will(returnValue(Collections.singletonList(message)));
oneOf(database).containsSubscription(txn, groupId);
oneOf(database).containsVisibleSubscription(txn, groupId,
contactId);
will(returnValue(false));
// The message is not stored but the batch must still be acked
oneOf(batch).getId();
@@ -807,10 +808,11 @@ public abstract class DatabaseComponentTest extends TestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
// Only store messages belonging to subscribed groups
// Only store messages belonging to visible, subscribed groups
oneOf(batch).getMessages();
will(returnValue(Collections.singletonList(message)));
oneOf(database).containsSubscription(txn, groupId);
oneOf(database).containsVisibleSubscription(txn, groupId,
contactId);
will(returnValue(true));
// The message is stored, but it's a duplicate
oneOf(database).addMessage(txn, message);
@@ -841,10 +843,11 @@ public abstract class DatabaseComponentTest extends TestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
// Only store messages belonging to subscribed groups
// Only store messages belonging to visible, subscribed groups
oneOf(batch).getMessages();
will(returnValue(Collections.singletonList(message)));
oneOf(database).containsSubscription(txn, groupId);
oneOf(database).containsVisibleSubscription(txn, groupId,
contactId);
will(returnValue(true));
// The message is stored, and it's not a duplicate
oneOf(database).addMessage(txn, message);
@@ -884,10 +887,11 @@ public abstract class DatabaseComponentTest extends TestCase {
allowing(database).commitTransaction(txn);
allowing(database).containsContact(txn, contactId);
will(returnValue(true));
// Only store messages belonging to subscribed groups
// Only store messages belonging to visible, subscribed groups
oneOf(batch).getMessages();
will(returnValue(Collections.singletonList(message)));
oneOf(database).containsSubscription(txn, groupId);
oneOf(database).containsVisibleSubscription(txn, groupId,
contactId);
will(returnValue(true));
// The message is stored, and it's not a duplicate
oneOf(database).addMessage(txn, message);