Skip to content
Snippets Groups Projects
Unverified Commit 8a20f330 authored by akwizgran's avatar akwizgran
Browse files

Broadcast status event when active contact is added.

parent 0f1dc554
No related branches found
No related tags found
No related merge requests found
...@@ -145,6 +145,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent { ...@@ -145,6 +145,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
throw new ContactExistsException(); throw new ContactExistsException();
ContactId c = db.addContact(txn, remote, local, active); ContactId c = db.addContact(txn, remote, local, active);
transaction.attach(new ContactAddedEvent(c)); transaction.attach(new ContactAddedEvent(c));
if (active) transaction.attach(new ContactStatusChangedEvent(c, true));
return c; return c;
} }
......
...@@ -16,6 +16,7 @@ import org.briarproject.api.db.NoSuchTransportException; ...@@ -16,6 +16,7 @@ import org.briarproject.api.db.NoSuchTransportException;
import org.briarproject.api.db.Transaction; import org.briarproject.api.db.Transaction;
import org.briarproject.api.event.ContactAddedEvent; import org.briarproject.api.event.ContactAddedEvent;
import org.briarproject.api.event.ContactRemovedEvent; import org.briarproject.api.event.ContactRemovedEvent;
import org.briarproject.api.event.ContactStatusChangedEvent;
import org.briarproject.api.event.EventBus; import org.briarproject.api.event.EventBus;
import org.briarproject.api.event.GroupAddedEvent; import org.briarproject.api.event.GroupAddedEvent;
import org.briarproject.api.event.GroupRemovedEvent; import org.briarproject.api.event.GroupRemovedEvent;
...@@ -146,6 +147,8 @@ public class DatabaseComponentImplTest extends BriarTestCase { ...@@ -146,6 +147,8 @@ public class DatabaseComponentImplTest extends BriarTestCase {
oneOf(database).addContact(txn, author, localAuthorId, true); oneOf(database).addContact(txn, author, localAuthorId, true);
will(returnValue(contactId)); will(returnValue(contactId));
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class))); oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
oneOf(eventBus).broadcast(with(any(
ContactStatusChangedEvent.class)));
// getContacts() // getContacts()
oneOf(database).getContacts(txn); oneOf(database).getContacts(txn);
will(returnValue(Collections.singletonList(contact))); will(returnValue(Collections.singletonList(contact)));
...@@ -768,6 +771,8 @@ public class DatabaseComponentImplTest extends BriarTestCase { ...@@ -768,6 +771,8 @@ public class DatabaseComponentImplTest extends BriarTestCase {
oneOf(database).addContact(txn, author, localAuthorId, true); oneOf(database).addContact(txn, author, localAuthorId, true);
will(returnValue(contactId)); will(returnValue(contactId));
oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class))); oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class)));
oneOf(eventBus).broadcast(with(any(
ContactStatusChangedEvent.class)));
// endTransaction() // endTransaction()
oneOf(database).commitTransaction(txn); oneOf(database).commitTransaction(txn);
// Check whether the transport is in the DB (which it's not) // Check whether the transport is in the DB (which it's not)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment