diff --git a/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt b/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt index a393d67a..e8f7678a 100644 --- a/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt +++ b/STCommon/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/common/interfaces/upload/UploadSession.kt @@ -25,6 +25,7 @@ interface UploadSession { val uuid: String val duration: ValidityPeriod get() = ValidityPeriod.THIRTY val authorEmail: String + val authorEmailToken: String? val password: String val message: String val numberOfDownload: DownloadLimit get() = DownloadLimit.TWO_HUNDRED_FIFTY diff --git a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt index 132ddc87..880a23a4 100644 --- a/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt +++ b/STCore/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/data/NewUploadSession.kt @@ -27,6 +27,7 @@ import com.infomaniak.multiplatform_swisstransfer.common.models.ValidityPeriod data class NewUploadSession( override val duration: ValidityPeriod, override val authorEmail: String, + override val authorEmailToken: String?, override val password: String, override val message: String, override val numberOfDownload: DownloadLimit, diff --git a/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt b/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt index f85e5c93..5dea3b65 100644 --- a/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt +++ b/STDatabase/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/database/models/upload/UploadSessionDB.kt @@ -33,6 +33,7 @@ class UploadSessionDB() : UploadSession, RealmObject { override var uuid: String = RealmUUID.random().toString() private var _duration: Int = AppSettingsDB.DEFAULT_VALIDITY_PERIOD.value override var authorEmail: String = "" + override var authorEmailToken: String? = null override var password: String = "" override var message: String = "" private var _numberOfDownload: Int = AppSettingsDB.DEFAULT_DOWNLOAD_LIMIT.value diff --git a/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt b/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt index 925570f4..a38f04d4 100644 --- a/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt +++ b/STDatabase/src/commonTest/kotlin/com/infomaniak/multiplatform_swisstransfer/database/dataset/DummyUpload.kt @@ -44,6 +44,7 @@ object DummyUpload { override val uuid: String = "upload1" override val duration: ValidityPeriod = ValidityPeriod.THIRTY override val authorEmail: String = "" + override val authorEmailToken: String? = null override val password: String = "" override val message: String = "" override val numberOfDownload: DownloadLimit = DownloadLimit.ONE diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/InitUploadBody.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/InitUploadBody.kt index a45868d0..00e2146f 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/InitUploadBody.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/models/upload/request/InitUploadBody.kt @@ -28,6 +28,7 @@ import kotlinx.serialization.json.Json class InitUploadBody( val duration: String = "", val authorEmail: String = "", + val authorEmailToken: String? = null, val password: String = "", val message: String = "", val sizeOfUpload: Long = 0L, @@ -43,6 +44,7 @@ class InitUploadBody( constructor(uploadSession: UploadSession, recaptcha: String) : this( duration = uploadSession.duration.value.toString(), authorEmail = uploadSession.authorEmail, + authorEmailToken = uploadSession.authorEmailToken, password = uploadSession.password, message = uploadSession.message, sizeOfUpload = uploadSession.files.sumOf { it.size }, diff --git a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt index 9a7c0c41..74d08246 100644 --- a/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt +++ b/STNetwork/src/commonMain/kotlin/com/infomaniak/multiplatform_swisstransfer/network/requests/UploadRequest.kt @@ -34,13 +34,18 @@ import io.ktor.client.request.setBody import io.ktor.http.ContentType import io.ktor.http.contentType import io.ktor.http.isSuccess +import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject internal class UploadRequest(json: Json, httpClient: HttpClient) : BaseRequest(json, httpClient) { suspend fun initUpload(initUploadBody: InitUploadBody): InitUploadResponseApi { - return post(url = createUrl(ApiRoutes.initUpload), initUploadBody) + val nullableJson = Json(json) { + explicitNulls = false + } + val encodedInitUploadBody = nullableJson.encodeToString(initUploadBody) + return post(url = createUrl(ApiRoutes.initUpload), encodedInitUploadBody) } suspend fun verifyEmailCode(verifyEmailCodeBody: VerifyEmailCodeBody): AuthorEmailToken {