2020-04-16 15:44:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Proton Technologies AG
|
2021-03-17 14:45:53 +00:00
|
|
|
*
|
2020-04-16 15:44:53 +00:00
|
|
|
* This file is part of ProtonMail.
|
2021-03-17 14:45:53 +00:00
|
|
|
*
|
2020-04-16 15:44:53 +00:00
|
|
|
* ProtonMail 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.
|
2021-03-17 14:45:53 +00:00
|
|
|
*
|
2020-04-16 15:44:53 +00:00
|
|
|
* ProtonMail 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.
|
2021-03-17 14:45:53 +00:00
|
|
|
*
|
2020-04-16 15:44:53 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with ProtonMail. If not, see https://www.gnu.org/licenses/.
|
|
|
|
*/
|
|
|
|
package ch.protonmail.android.activities.messageDetails
|
|
|
|
|
|
|
|
import android.os.AsyncTask
|
|
|
|
import ch.protonmail.android.core.ProtonMailApplication
|
2021-03-17 14:45:53 +00:00
|
|
|
import ch.protonmail.android.data.local.MessageDatabase
|
2021-03-18 09:46:25 +00:00
|
|
|
import ch.protonmail.android.data.local.model.Message
|
2020-04-16 15:44:53 +00:00
|
|
|
import ch.protonmail.android.jobs.FetchMessageDetailJob
|
2021-08-25 11:23:27 +00:00
|
|
|
import ch.protonmail.android.labels.data.LabelRepository
|
2020-04-16 15:44:53 +00:00
|
|
|
|
2021-08-25 11:23:27 +00:00
|
|
|
internal class RegisterReloadTask(
|
|
|
|
private val message: Message,
|
|
|
|
private val labelRepository: LabelRepository
|
|
|
|
) : AsyncTask<Void, Void, Void>() {
|
2020-04-16 15:44:53 +00:00
|
|
|
|
2021-05-17 15:24:39 +00:00
|
|
|
override fun doInBackground(vararg voids: Void): Void? {
|
|
|
|
val app = ProtonMailApplication.getApplication()
|
|
|
|
val messagesDatabase = MessageDatabase.getInstance(app, app.userManager.requireCurrentUserId()).getDao()
|
|
|
|
val jobManager = app.jobManager
|
|
|
|
if (message.checkIfAttHeadersArePresent(messagesDatabase)) {
|
2021-08-25 11:23:27 +00:00
|
|
|
jobManager.addJobInBackground(FetchMessageDetailJob(message.messageId, labelRepository))
|
2021-05-17 15:24:39 +00:00
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
2020-04-16 15:44:53 +00:00
|
|
|
}
|