mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Address review comments for detecting duplicate (pending) contacts
This commit is contained in:
@@ -144,6 +144,7 @@ public interface ContactManager {
|
|||||||
/**
|
/**
|
||||||
* Returns the state of the given {@link PendingContact}.
|
* Returns the state of the given {@link PendingContact}.
|
||||||
*/
|
*/
|
||||||
|
@Nullable
|
||||||
PendingContactState getPendingContactState(PendingContactId p);
|
PendingContactState getPendingContactState(PendingContactId p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -173,6 +173,7 @@ class ContactManagerImpl implements ContactManager, EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Nullable
|
||||||
public PendingContactState getPendingContactState(PendingContactId p) {
|
public PendingContactState getPendingContactState(PendingContactId p) {
|
||||||
return states.get(p);
|
return states.get(p);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1480,7 +1480,11 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
ps.setBytes(1, handshakePublicKey.getEncoded());
|
ps.setBytes(1, handshakePublicKey.getEncoded());
|
||||||
ps.setBytes(2, localAuthorId.getBytes());
|
ps.setBytes(2, localAuthorId.getBytes());
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
if (!rs.next()) return null;
|
if (!rs.next()) {
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
ContactId contactId = new ContactId(rs.getInt(1));
|
ContactId contactId = new ContactId(rs.getInt(1));
|
||||||
AuthorId authorId = new AuthorId(rs.getBytes(2));
|
AuthorId authorId = new AuthorId(rs.getBytes(2));
|
||||||
int formatVersion = rs.getInt(3);
|
int formatVersion = rs.getInt(3);
|
||||||
@@ -1488,7 +1492,7 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
String alias = rs.getString(5);
|
String alias = rs.getString(5);
|
||||||
PublicKey publicKey = new SignaturePublicKey(rs.getBytes(6));
|
PublicKey publicKey = new SignaturePublicKey(rs.getBytes(6));
|
||||||
boolean verified = rs.getBoolean(7);
|
boolean verified = rs.getBoolean(7);
|
||||||
if (rs.next()) throw new DbException();
|
if (rs.next()) throw new DbStateException();
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
Author author =
|
Author author =
|
||||||
|
|||||||
@@ -120,8 +120,10 @@ public class NicknameFragment extends BaseFragment {
|
|||||||
|
|
||||||
viewModel.getAddContactResult().observe(this, result -> {
|
viewModel.getAddContactResult().observe(this, result -> {
|
||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
if (result.hasError()) handleException(name, result.getException());
|
if (result.hasError())
|
||||||
else showPendingContactListActivity();
|
handleException(name, requireNonNull(result.getException()));
|
||||||
|
else
|
||||||
|
showPendingContactListActivity();
|
||||||
});
|
});
|
||||||
viewModel.addContact(name);
|
viewModel.addContact(name);
|
||||||
}
|
}
|
||||||
@@ -133,7 +135,7 @@ public class NicknameFragment extends BaseFragment {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleException(String name, @Nullable Exception e) {
|
private void handleException(String name, Exception e) {
|
||||||
if (e instanceof ContactExistsException) {
|
if (e instanceof ContactExistsException) {
|
||||||
ContactExistsException ce = (ContactExistsException) e;
|
ContactExistsException ce = (ContactExistsException) e;
|
||||||
handleExistingContact(name, ce.getRemoteAuthor());
|
handleExistingContact(name, ce.getRemoteAuthor());
|
||||||
|
|||||||
Reference in New Issue
Block a user