Skip to content

Commit

Permalink
feat(mls): add delete key-packages api (WPB-1003) (#2151)
Browse files Browse the repository at this point in the history
* feat(mls): add delete key-packages api

* update APINotSupportedMessage for deleteKeyPackagesApi
  • Loading branch information
mchenani authored Oct 19, 2023
1 parent 49bd46f commit 3b1d9b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ interface KeyPackageApi {
*/
suspend fun uploadKeyPackages(clientId: String, keyPackages: List<KeyPackage>): NetworkResponse<Unit>

/**
* Delete a batch key packages from the server
*
* @param clientId client ID
* @param keyPackages list of key packages
*
*/
suspend fun deleteKeyPackages(clientId: String, keyPackages: List<KeyPackage>): NetworkResponse<Unit>

/**
* Get the number of available key packages for the self client
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ internal open class KeyPackageApiV0 internal constructor() : KeyPackageApi {
APINotSupported("MLS: uploadKeyPackages api is only available on API V5")
)

override suspend fun deleteKeyPackages(
clientId: String,
keyPackages: List<KeyPackage>
): NetworkResponse<Unit> = NetworkResponse.Error(
APINotSupported("MLS: uploadKeyPackages api is only available on API V5")
)

override suspend fun getAvailableKeyPackageCount(clientId: String): NetworkResponse<KeyPackageCountDTO> =
NetworkResponse.Error(
APINotSupported("MLS: getAvailableKeyPackageCount api is only available on API V5")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.wire.kalium.network.api.v4.authenticated.KeyPackageApiV4
import com.wire.kalium.network.kaliumLogger
import com.wire.kalium.network.utils.NetworkResponse
import com.wire.kalium.network.utils.wrapKaliumResponse
import io.ktor.client.request.delete
import io.ktor.client.request.get
import io.ktor.client.request.parameter
import io.ktor.client.request.post
Expand All @@ -53,12 +54,23 @@ internal open class KeyPackageApiV5 internal constructor(
keyPackages: List<KeyPackage>
): NetworkResponse<Unit> =
wrapKaliumResponse {
kaliumLogger.v("Keypackages Count: ${keyPackages.size}")
kaliumLogger.v("Keypackages Count to upload: ${keyPackages.size}")
httpClient.post("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId") {
setBody(KeyPackageList(keyPackages))
}
}

override suspend fun deleteKeyPackages(
clientId: String,
keyPackages: List<KeyPackage>
): NetworkResponse<Unit> =
wrapKaliumResponse {
kaliumLogger.v("Keypackages Count to delete: ${keyPackages.size}")
httpClient.delete("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId") {
setBody(KeyPackageList(keyPackages))
}
}

override suspend fun getAvailableKeyPackageCount(clientId: String): NetworkResponse<KeyPackageCountDTO> =
wrapKaliumResponse { httpClient.get("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId/$PATH_COUNT") }

Expand Down

0 comments on commit 3b1d9b2

Please sign in to comment.