diff --git a/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java b/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java index 0980962b06d11b0228201359d783f7ddd7882200..a912407513482683afdb1e4f97fd61d025b981c5 100644 --- a/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java +++ b/briar-core/src/org/briarproject/db/DatabaseComponentImpl.java @@ -145,6 +145,7 @@ class DatabaseComponentImpl<T> implements DatabaseComponent { throw new ContactExistsException(); ContactId c = db.addContact(txn, remote, local, active); transaction.attach(new ContactAddedEvent(c)); + if (active) transaction.attach(new ContactStatusChangedEvent(c, true)); return c; } diff --git a/briar-tests/src/org/briarproject/db/DatabaseComponentImplTest.java b/briar-tests/src/org/briarproject/db/DatabaseComponentImplTest.java index 17c27f9541472fff0f63e358f3ab493a33bc4cd7..4049a4091db098696bf672b5b4a6fdffbb343f79 100644 --- a/briar-tests/src/org/briarproject/db/DatabaseComponentImplTest.java +++ b/briar-tests/src/org/briarproject/db/DatabaseComponentImplTest.java @@ -16,6 +16,7 @@ import org.briarproject.api.db.NoSuchTransportException; import org.briarproject.api.db.Transaction; import org.briarproject.api.event.ContactAddedEvent; import org.briarproject.api.event.ContactRemovedEvent; +import org.briarproject.api.event.ContactStatusChangedEvent; import org.briarproject.api.event.EventBus; import org.briarproject.api.event.GroupAddedEvent; import org.briarproject.api.event.GroupRemovedEvent; @@ -146,6 +147,8 @@ public class DatabaseComponentImplTest extends BriarTestCase { oneOf(database).addContact(txn, author, localAuthorId, true); will(returnValue(contactId)); oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class))); + oneOf(eventBus).broadcast(with(any( + ContactStatusChangedEvent.class))); // getContacts() oneOf(database).getContacts(txn); will(returnValue(Collections.singletonList(contact))); @@ -768,6 +771,8 @@ public class DatabaseComponentImplTest extends BriarTestCase { oneOf(database).addContact(txn, author, localAuthorId, true); will(returnValue(contactId)); oneOf(eventBus).broadcast(with(any(ContactAddedEvent.class))); + oneOf(eventBus).broadcast(with(any( + ContactStatusChangedEvent.class))); // endTransaction() oneOf(database).commitTransaction(txn); // Check whether the transport is in the DB (which it's not)