mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Actually throw TolerableFailureException when *deleting* a contact
Before, this was accidentally added to *listing* contacts.
This commit is contained in:
@@ -43,20 +43,20 @@ interface MailboxApi {
|
||||
/**
|
||||
* Deletes a contact from the mailbox.
|
||||
* This should get called after a contact was removed from Briar.
|
||||
*/
|
||||
void deleteContact(MailboxProperties properties, ContactId contactId)
|
||||
throws IOException, ApiException;
|
||||
|
||||
/**
|
||||
* Gets a list of {@link ContactId}s from the mailbox.
|
||||
* These are the contacts that the mailbox already knows about.
|
||||
*
|
||||
* @throws TolerableFailureException if response code is 404
|
||||
* (contact probably was already deleted).
|
||||
*/
|
||||
Collection<ContactId> getContacts(MailboxProperties properties)
|
||||
void deleteContact(MailboxProperties properties, ContactId contactId)
|
||||
throws IOException, ApiException, TolerableFailureException;
|
||||
|
||||
/**
|
||||
* Gets a list of {@link ContactId}s from the mailbox.
|
||||
* These are the contacts that the mailbox already knows about.
|
||||
*/
|
||||
Collection<ContactId> getContacts(MailboxProperties properties)
|
||||
throws IOException, ApiException;
|
||||
|
||||
@Immutable
|
||||
@JsonSerialize
|
||||
class MailboxContact {
|
||||
|
||||
@@ -113,7 +113,7 @@ class MailboxApiImpl implements MailboxApi {
|
||||
|
||||
@Override
|
||||
public void deleteContact(MailboxProperties properties, ContactId contactId)
|
||||
throws IOException, ApiException {
|
||||
throws IOException, ApiException, TolerableFailureException {
|
||||
if (!properties.isOwner()) throw new IllegalArgumentException();
|
||||
String url = properties.getOnionAddress() + "/contacts/" +
|
||||
contactId.getInt();
|
||||
@@ -123,15 +123,15 @@ class MailboxApiImpl implements MailboxApi {
|
||||
.build();
|
||||
OkHttpClient client = httpClientProvider.get();
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.code() == 404) throw new TolerableFailureException();
|
||||
if (response.code() != 200) throw new ApiException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ContactId> getContacts(MailboxProperties properties)
|
||||
throws IOException, ApiException, TolerableFailureException {
|
||||
throws IOException, ApiException {
|
||||
if (!properties.isOwner()) throw new IllegalArgumentException();
|
||||
Response response = sendGetRequest(properties, "/contacts");
|
||||
if (response.code() == 404) throw new TolerableFailureException();
|
||||
if (response.code() != 200) throw new ApiException();
|
||||
|
||||
ResponseBody body = response.body();
|
||||
|
||||
Reference in New Issue
Block a user