Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add authorEmailToken #115

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import kotlinx.serialization.json.Json
class InitUploadBody(
val duration: String = "",
val authorEmail: String = "",
val authorEmailToken: String? = null,
tevincent marked this conversation as resolved.
Show resolved Hide resolved
val password: String = "",
val message: String = "",
val sizeOfUpload: Long = 0L,
Expand All @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading