Use status endpoint for contact connectivity check.

This commit is contained in:
akwizgran
2022-05-27 13:00:43 +01:00
parent 6b790b59fa
commit 34337486e9
2 changed files with 6 additions and 11 deletions

View File

@@ -9,8 +9,6 @@ import java.io.IOException;
import javax.annotation.concurrent.ThreadSafe;
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
@ThreadSafe
@NotNullByDefault
class ContactMailboxConnectivityChecker extends ConnectivityCheckerImpl {
@@ -29,8 +27,9 @@ class ContactMailboxConnectivityChecker extends ConnectivityCheckerImpl {
return new SimpleApiCall() {
@Override
void tryToCallApi() throws IOException, ApiException {
mailboxApi.getFiles(properties,
requireNonNull(properties.getInboxId()));
if (!mailboxApi.checkStatus(properties)) {
throw new ApiException();
}
// Call the observers and cache the result
onConnectivityCheckSucceeded(clock.currentTimeMillis());
}

View File

@@ -13,8 +13,6 @@ import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
import static java.util.Collections.emptyList;
import static org.briarproject.bramble.api.nullsafety.NullSafety.requireNonNull;
import static org.briarproject.bramble.mailbox.MailboxApi.CLIENT_SUPPORTS;
import static org.briarproject.bramble.test.TestUtils.getMailboxProperties;
import static org.junit.Assert.assertFalse;
@@ -54,9 +52,8 @@ public class ContactMailboxConnectivityCheckerTest extends BrambleMockTestCase {
// When the check succeeds the observer should be called
context.checking(new Expectations() {{
oneOf(mailboxApi).getFiles(properties,
requireNonNull(properties.getInboxId()));
will(returnValue(emptyList()));
oneOf(mailboxApi).checkStatus(properties);
will(returnValue(true));
oneOf(clock).currentTimeMillis();
will(returnValue(now));
oneOf(observer).onConnectivityCheckSucceeded();
@@ -86,8 +83,7 @@ public class ContactMailboxConnectivityCheckerTest extends BrambleMockTestCase {
// When the check fails, the observer should not be called
context.checking(new Expectations() {{
oneOf(mailboxApi).getFiles(properties,
requireNonNull(properties.getInboxId()));
oneOf(mailboxApi).checkStatus(properties);
will(throwException(new IOException()));
}});