Add deletion method to ArchiveApi.
This commit is contained in:
parent
f25a2f79ce
commit
cc87da13db
2 changed files with 42 additions and 3 deletions
|
@ -151,8 +151,17 @@ class ArchiveApi(private val pushServiceSocket: PushServiceSocket) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Backup keep-alive that informs the server that the backup is still in use. If a backup is not refreshed, it may be deleted
|
||||
* after 30 days.
|
||||
* Indicate that this backup is still active. Clients must periodically upload new backups or perform a refresh via a POST request. If a backup is not
|
||||
* refreshed, after 30 days it may be deleted.
|
||||
*
|
||||
* POST /v1/archives
|
||||
*
|
||||
* - 204: The backup was successfully refreshed.
|
||||
* - 400: Bad arguments. The request may have been made on an authenticated channel.
|
||||
* - 401: The provided backup auth credential presentation could not be verified or The public key signature was invalid or There is no backup associated with
|
||||
* the backup-id in the presentation or The credential was of the wrong type (messages/media)
|
||||
* - 403: Forbidden. The request had insufficient permissions to perform the requested action.
|
||||
* - 429: Rate limited.
|
||||
*/
|
||||
fun refreshBackup(aci: ACI, archiveServiceAccess: ArchiveServiceAccess<MessageBackupKey>): NetworkResult<Unit> {
|
||||
return NetworkResult.fromFetch {
|
||||
|
@ -162,6 +171,27 @@ class ArchiveApi(private val pushServiceSocket: PushServiceSocket) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all backup metadata, objects, and stored public key. To use backups again, a public key must be resupplied.
|
||||
*
|
||||
* DELETE /v1/archives
|
||||
*
|
||||
* - 204: The backup has been successfully deleted
|
||||
* - 400: Bad arguments. The request may have been made on an authenticated channel.
|
||||
* - 401: The provided backup auth credential presentation could not be verified or The public key signature was invalid or There is no backup associated with
|
||||
* the backup-id in the presentation or The credential was of the wrong type (messages/media)
|
||||
* - 403: Forbidden. The request had insufficient permissions to perform the requested action.
|
||||
* - 429: Rate limited.
|
||||
*
|
||||
*/
|
||||
fun deleteBackup(aci: ACI, archiveServiceAccess: ArchiveServiceAccess<MessageBackupKey>): NetworkResult<Unit> {
|
||||
return NetworkResult.fromFetch {
|
||||
val zkCredential = getZkCredential(aci, archiveServiceAccess)
|
||||
val presentationData = CredentialPresentationData.from(archiveServiceAccess.backupKey, aci, zkCredential, backupServerPublicParams)
|
||||
pushServiceSocket.deleteBackup(presentationData.toArchiveCredentialPresentation())
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists the media objects in the backup
|
||||
*/
|
||||
|
|
|
@ -569,7 +569,16 @@ public class PushServiceSocket {
|
|||
public void refreshBackup(ArchiveCredentialPresentation credentialPresentation) throws IOException {
|
||||
Map<String, String> headers = credentialPresentation.toHeaders();
|
||||
|
||||
makeServiceRequestWithoutAuthentication(ARCHIVE_INFO, "POST", null, headers, NO_HANDLER);
|
||||
makeServiceRequestWithoutAuthentication(ARCHIVE_INFO, "POST", null, headers, UNOPINIONATED_HANDLER);
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE credential presentation to the server to delete backup.
|
||||
*/
|
||||
public void deleteBackup(ArchiveCredentialPresentation credentialPresentation) throws IOException {
|
||||
Map<String, String> headers = credentialPresentation.toHeaders();
|
||||
|
||||
makeServiceRequestWithoutAuthentication(ARCHIVE_INFO, "DELETE", null, headers, UNOPINIONATED_HANDLER);
|
||||
}
|
||||
|
||||
public List<ArchiveGetMediaItemsResponse.StoredMediaObject> debugGetAllArchiveMediaItems(ArchiveCredentialPresentation credentialPresentation) throws IOException {
|
||||
|
|
Loading…
Add table
Reference in a new issue