mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 04:18:53 +01:00
Broadcast status event when active contact is added.
This commit is contained in:
@@ -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;
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user