Add a contactExists() method to the contactManager

This requires exposing the `containsContact()` method to the `DatabaseComponent`
and is needed for finding out efficiently whether a contact already exists.
This commit is contained in:
Torsten Grote
2016-02-18 14:46:43 -02:00
parent e2d64e0a8c
commit 5bde14c694
4 changed files with 44 additions and 0 deletions

View File

@@ -342,6 +342,14 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
return db.getContacts(txn, a);
}
public boolean containsContact(Transaction transaction, AuthorId remote,
AuthorId local) throws DbException {
T txn = unbox(transaction);
if (!db.containsLocalAuthor(txn, local))
throw new NoSuchLocalAuthorException();
return db.containsContact(txn, remote, local);
}
public DeviceId getDeviceId(Transaction transaction) throws DbException {
T txn = unbox(transaction);
return db.getDeviceId(txn);