mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Add a new event that is broadcasted when a contact is verified
Also, don't support unverifying contacts.
This commit is contained in:
@@ -576,10 +576,9 @@ interface Database<T> {
|
||||
void resetExpiryTime(T txn, ContactId c, MessageId m) throws DbException;
|
||||
|
||||
/**
|
||||
* Marks the given contact as verified or unverified.
|
||||
* Marks the given contact as verified.
|
||||
*/
|
||||
void setContactVerified(T txn, ContactId c, boolean verified)
|
||||
throws DbException;
|
||||
void setContactVerified(T txn, ContactId c) throws DbException;
|
||||
|
||||
/**
|
||||
* Marks the given contact as active or inactive.
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.event.ContactAddedEvent;
|
||||
import org.briarproject.api.event.ContactRemovedEvent;
|
||||
import org.briarproject.api.event.ContactStatusChangedEvent;
|
||||
import org.briarproject.api.event.ContactVerifiedEvent;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.event.GroupAddedEvent;
|
||||
@@ -683,14 +684,14 @@ class DatabaseComponentImpl<T> implements DatabaseComponent {
|
||||
db.removeTransport(txn, t);
|
||||
}
|
||||
|
||||
public void setContactVerified(Transaction transaction, ContactId c,
|
||||
boolean verified) throws DbException {
|
||||
public void setContactVerified(Transaction transaction, ContactId c)
|
||||
throws DbException {
|
||||
if (transaction.isReadOnly()) throw new IllegalArgumentException();
|
||||
T txn = unbox(transaction);
|
||||
if (!db.containsContact(txn, c))
|
||||
throw new NoSuchContactException();
|
||||
db.setContactVerified(txn, c, verified);
|
||||
transaction.attach(new ContactStatusChangedEvent(c, verified));
|
||||
db.setContactVerified(txn, c);
|
||||
transaction.attach(new ContactVerifiedEvent(c));
|
||||
}
|
||||
|
||||
public void setContactActive(Transaction transaction, ContactId c,
|
||||
|
||||
@@ -2249,13 +2249,13 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
}
|
||||
}
|
||||
|
||||
public void setContactVerified(Connection txn, ContactId c,
|
||||
boolean verified) throws DbException {
|
||||
public void setContactVerified(Connection txn, ContactId c)
|
||||
throws DbException {
|
||||
PreparedStatement ps = null;
|
||||
try {
|
||||
String sql = "UPDATE contacts SET verified = ? WHERE contactId = ?";
|
||||
ps = txn.prepareStatement(sql);
|
||||
ps.setBoolean(1, verified);
|
||||
ps.setBoolean(1, true);
|
||||
ps.setInt(2, c.getInt());
|
||||
int affected = ps.executeUpdate();
|
||||
if (affected < 0 || affected > 1) throw new DbStateException();
|
||||
|
||||
Reference in New Issue
Block a user