Use extended timeout for sending as it can contain attachments in the
case of PGP/MIME messages
This commit is contained in:
parent
006f4144a9
commit
95a3191efd
|
@ -32,10 +32,9 @@ import ch.protonmail.android.api.segments.device.DeviceApi
|
|||
import ch.protonmail.android.api.segments.device.DeviceApiSpec
|
||||
import ch.protonmail.android.api.segments.key.KeyApi
|
||||
import ch.protonmail.android.api.segments.key.KeyApiSpec
|
||||
import ch.protonmail.android.labels.data.remote.LabelApi
|
||||
import ch.protonmail.android.labels.data.remote.LabelApiSpec
|
||||
import ch.protonmail.android.api.segments.message.MessageApi
|
||||
import ch.protonmail.android.api.segments.message.MessageApiSpec
|
||||
import ch.protonmail.android.api.segments.message.MessageSendService
|
||||
import ch.protonmail.android.api.segments.organization.OrganizationApi
|
||||
import ch.protonmail.android.api.segments.organization.OrganizationApiSpec
|
||||
import ch.protonmail.android.api.segments.report.ReportApi
|
||||
|
@ -43,6 +42,8 @@ import ch.protonmail.android.api.segments.report.ReportApiSpec
|
|||
import ch.protonmail.android.api.segments.settings.mail.MailSettingsApi
|
||||
import ch.protonmail.android.api.segments.settings.mail.MailSettingsApiSpec
|
||||
import ch.protonmail.android.di.ConfigurableProtonRetrofitBuilder
|
||||
import ch.protonmail.android.labels.data.remote.LabelApi
|
||||
import ch.protonmail.android.labels.data.remote.LabelApiSpec
|
||||
import ch.protonmail.android.mailbox.data.remote.ConversationApi
|
||||
import ch.protonmail.android.mailbox.data.remote.ConversationApiSpec
|
||||
import me.proton.core.network.data.ApiProvider
|
||||
|
@ -118,6 +119,8 @@ class ProtonMailApi private constructor(
|
|||
// region config
|
||||
val services = SecuredServices(protonRetrofitBuilder.provideRetrofit(RetrofitType.SECURE))
|
||||
val servicePing = protonRetrofitBuilder.provideRetrofit(RetrofitType.PING).create(PingService::class.java)
|
||||
val messageSendService = protonRetrofitBuilder.provideRetrofit(RetrofitType.EXTENDED_TIMEOUT)
|
||||
.create(MessageSendService::class.java)
|
||||
val mUploadService = protonRetrofitBuilder.provideRetrofit(RetrofitType.EXTENDED_TIMEOUT)
|
||||
.create(AttachmentUploadService::class.java)
|
||||
val mAttachmentsService = protonRetrofitBuilder.provideRetrofit(RetrofitType.ATTACHMENTS)
|
||||
|
@ -128,7 +131,7 @@ class ProtonMailApi private constructor(
|
|||
val contactApi = ContactApi(services.contact)
|
||||
val deviceApi = DeviceApi(services.device)
|
||||
val keyApi = KeyApi(services.key)
|
||||
val messageApi = MessageApi(services.message)
|
||||
val messageApi = MessageApi(services.message, messageSendService)
|
||||
val conversationApi = ConversationApi(services.conversation)
|
||||
val labelApi = LabelApi(apiProvider)
|
||||
val organizationApi = OrganizationApi(apiProvider)
|
||||
|
|
|
@ -37,7 +37,10 @@ import me.proton.core.domain.entity.UserId
|
|||
import timber.log.Timber
|
||||
import java.io.IOException
|
||||
|
||||
class MessageApi(private val service: MessageService) : BaseApi(), MessageApiSpec {
|
||||
class MessageApi(
|
||||
private val service: MessageService,
|
||||
private val sendService: MessageSendService
|
||||
) : BaseApi(), MessageApiSpec {
|
||||
|
||||
override suspend fun fetchMessagesCounts(userId: UserId): CountsResponse =
|
||||
service.fetchMessagesCounts(UserIdTag(userId))
|
||||
|
@ -107,7 +110,7 @@ class MessageApi(private val service: MessageService) : BaseApi(), MessageApiSpe
|
|||
messageId: String,
|
||||
message: MessageSendBody,
|
||||
userIdTag: UserIdTag
|
||||
): MessageSendResponse = service.sendMessage(messageId, message, userIdTag)
|
||||
): MessageSendResponse = sendService.sendMessage(messageId, message, userIdTag)
|
||||
|
||||
@Throws(IOException::class)
|
||||
override fun unlabelMessages(idList: IDList) {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Proton AG
|
||||
*
|
||||
* This file is part of Proton Mail.
|
||||
*
|
||||
* Proton Mail is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Proton Mail is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Proton Mail. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
package ch.protonmail.android.api.segments.message
|
||||
|
||||
import ch.protonmail.android.api.interceptors.UserIdTag
|
||||
import ch.protonmail.android.api.models.messages.send.MessageSendBody
|
||||
import ch.protonmail.android.api.models.messages.send.MessageSendResponse
|
||||
import ch.protonmail.android.api.segments.RetrofitConstants.ACCEPT_HEADER_V1
|
||||
import ch.protonmail.android.api.segments.RetrofitConstants.CONTENT_TYPE
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.Headers
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Path
|
||||
import retrofit2.http.Tag
|
||||
|
||||
interface MessageSendService {
|
||||
|
||||
@POST("mail/v4/messages/{messageId}")
|
||||
@Headers(CONTENT_TYPE, ACCEPT_HEADER_V1)
|
||||
suspend fun sendMessage(
|
||||
@Path("messageId") messageId: String,
|
||||
@Body message: MessageSendBody,
|
||||
@Tag userIdTag: UserIdTag
|
||||
): MessageSendResponse
|
||||
|
||||
}
|
|
@ -26,8 +26,6 @@ import ch.protonmail.android.api.models.MoveToFolderResponse
|
|||
import ch.protonmail.android.api.models.messages.delete.MessageDeleteRequest
|
||||
import ch.protonmail.android.api.models.messages.receive.MessageResponse
|
||||
import ch.protonmail.android.api.models.messages.receive.MessagesResponse
|
||||
import ch.protonmail.android.api.models.messages.send.MessageSendBody
|
||||
import ch.protonmail.android.api.models.messages.send.MessageSendResponse
|
||||
import ch.protonmail.android.api.segments.RetrofitConstants.ACCEPT_HEADER_V1
|
||||
import ch.protonmail.android.api.segments.RetrofitConstants.CONTENT_TYPE
|
||||
import ch.protonmail.android.mailbox.data.remote.model.CountsResponse
|
||||
|
@ -100,14 +98,6 @@ interface MessageService {
|
|||
@Tag userIdTag: UserIdTag
|
||||
): MessageResponse
|
||||
|
||||
@POST("mail/v4/messages/{messageId}")
|
||||
@Headers(CONTENT_TYPE, ACCEPT_HEADER_V1)
|
||||
suspend fun sendMessage(
|
||||
@Path("messageId") messageId: String,
|
||||
@Body message: MessageSendBody,
|
||||
@Tag userIdTag: UserIdTag
|
||||
): MessageSendResponse
|
||||
|
||||
@GET("mail/v4/messages/{messageId}")
|
||||
@Headers(ACCEPT_HEADER_V1)
|
||||
fun fetchMessageDetailsBlocking(@Path("messageId") messageId: String): Call<MessageResponse>
|
||||
|
|
Loading…
Reference in New Issue