Add transactional version of removePendingContact()

This commit is contained in:
Sebastian Kürten
2022-02-15 22:28:29 +01:00
parent 80cac277ac
commit 7ae91a984f
2 changed files with 17 additions and 3 deletions

View File

@@ -178,6 +178,12 @@ public interface ContactManager {
*/
void removePendingContact(PendingContactId p) throws DbException;
/**
* Removes a {@link PendingContact}.
*/
void removePendingContact(Transaction txn, PendingContactId p)
throws DbException;
/**
* Returns the contact with the given ID.
*/

View File

@@ -131,7 +131,8 @@ class ContactManagerImpl implements ContactManager, EventListener {
}
@Override
public PendingContact addPendingContact(Transaction txn, String link, String alias)
public PendingContact addPendingContact(Transaction txn, String link,
String alias)
throws DbException, FormatException, GeneralSecurityException {
PendingContact p =
pendingContactFactory.createPendingContact(link, alias);
@@ -169,7 +170,8 @@ class ContactManagerImpl implements ContactManager, EventListener {
}
@Override
public Collection<Pair<PendingContact, PendingContactState>> getPendingContacts(Transaction txn)
public Collection<Pair<PendingContact, PendingContactState>> getPendingContacts(
Transaction txn)
throws DbException {
Collection<PendingContact> pendingContacts = db.getPendingContacts(txn);
List<Pair<PendingContact, PendingContactState>> pairs =
@@ -184,7 +186,13 @@ class ContactManagerImpl implements ContactManager, EventListener {
@Override
public void removePendingContact(PendingContactId p) throws DbException {
db.transaction(false, txn -> db.removePendingContact(txn, p));
db.transaction(false, txn -> removePendingContact(txn, p));
}
@Override
public void removePendingContact(Transaction txn, PendingContactId p)
throws DbException {
db.removePendingContact(txn, p);
states.remove(p);
}