mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Merge branch '118-contact-introductions' into 'master'
Contact Introduction Backend This MR allows you to introduce two of your contacts to each other. They both will receive an introduction with an optional message and then can accept or refuse the introduction which is presented as a notification. When reviewing, I propose to review the individual commits separately as I took great care to split functional independent parts into separate commits. You might also want to have a look at the [Introduction Client Wiki page](https://code.briarproject.org/akwizgran/briar/wikis/IntroductionClient) to better understand what is going on before looking into the actual code. Protocol sessions and states are not yet deleted and the UI is still missing (#253). In order to practically test this feature, the UI from !122 is needed. See merge request !116
This commit is contained in:
@@ -46,6 +46,18 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
removeHooks.add(hook);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactId addContact(Transaction txn, Author remote, AuthorId local,
|
||||
SecretKey master,long timestamp, boolean alice, boolean active)
|
||||
throws DbException {
|
||||
ContactId c = db.addContact(txn, remote, local, active);
|
||||
keyManager.addContact(txn, c, master, timestamp, alice);
|
||||
Contact contact = db.getContact(txn, c);
|
||||
for (AddContactHook hook : addHooks)
|
||||
hook.addingContact(txn, contact);
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactId addContact(Author remote, AuthorId local, SecretKey master,
|
||||
long timestamp, boolean alice, boolean active)
|
||||
@@ -53,11 +65,8 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
ContactId c;
|
||||
Transaction txn = db.startTransaction(false);
|
||||
try {
|
||||
c = db.addContact(txn, remote, local, active);
|
||||
keyManager.addContact(txn, c, master, timestamp, alice);
|
||||
Contact contact = db.getContact(txn, c);
|
||||
for (AddContactHook hook : addHooks)
|
||||
hook.addingContact(txn, contact);
|
||||
c = addContact(txn, remote, local, master, timestamp, alice,
|
||||
active);
|
||||
txn.setComplete();
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
@@ -116,6 +125,26 @@ class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contactExists(Transaction txn, AuthorId remoteAuthorID,
|
||||
AuthorId localAuthorId) throws DbException {
|
||||
return db.containsContact(txn, remoteAuthorID, localAuthorId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contactExists(AuthorId remoteAuthorID,
|
||||
AuthorId localAuthorId) throws DbException {
|
||||
boolean exists = false;
|
||||
Transaction txn = db.startTransaction(true);
|
||||
try {
|
||||
exists = contactExists(txn, remoteAuthorID, localAuthorId);
|
||||
txn.setComplete();
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
||||
private void removeContact(Transaction txn, ContactId c)
|
||||
throws DbException {
|
||||
Contact contact = db.getContact(txn, c);
|
||||
|
||||
Reference in New Issue
Block a user