Address mailbox pairing backend review feedback

This commit is contained in:
Torsten Grote
2022-02-18 09:50:38 -03:00
parent 88c54ed3b0
commit 4a46b13e9d
4 changed files with 15 additions and 16 deletions

View File

@@ -98,30 +98,28 @@ class MailboxPairingTaskImpl implements MailboxPairingTask {
} catch (IOException e) {
onMailboxError(e, new MailboxPairingState.ConnectionError(payload));
} catch (ApiException | DbException e) {
onMailboxError(e, new MailboxPairingState.AssertionError(payload));
onMailboxError(e, new MailboxPairingState.UnexpectedError(payload));
}
}
private void pairMailbox() throws IOException, ApiException, DbException {
MailboxProperties mailboxProperties = decodeQrCodePayload(payload);
synchronized (lock) {
this.state = new MailboxPairingState.Pairing(payload);
notifyObservers();
}
setState(new MailboxPairingState.Pairing(payload));
MailboxAuthToken ownerToken = api.setup(mailboxProperties);
MailboxProperties ownerProperties = new MailboxProperties(
mailboxProperties.getBaseUrl(), ownerToken, true);
db.transaction(false, txn -> mailboxSettingsManager
.setOwnMailboxProperties(txn, ownerProperties));
synchronized (lock) {
this.state = new MailboxPairingState.Paired();
notifyObservers();
}
setState(new MailboxPairingState.Paired());
// TODO already do mailboxSettingsManager.setOwnMailboxStatus() ?
}
private void onMailboxError(Exception e, MailboxPairingState state) {
logException(LOG, WARNING, e);
setState(state);
}
private void setState(MailboxPairingState state) {
synchronized (lock) {
this.state = state;
notifyObservers();

View File

@@ -3,6 +3,7 @@ package org.briarproject.bramble.plugin.file;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import org.briarproject.bramble.api.plugin.file.RemovableDriveTask;
@Deprecated // We can simply remove tasks when they finish
@NotNullByDefault
interface RemovableDriveTaskRegistry {