Remove use of EmailHelper
from :feature:autodiscovery:autoconfig
This commit is contained in:
parent
eb4a414c58
commit
27ba2b5d8d
3 changed files with 9 additions and 14 deletions
|
@ -4,8 +4,8 @@ import app.k9mail.autodiscovery.api.AutoDiscovery
|
|||
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
|
||||
import app.k9mail.autodiscovery.api.AutoDiscoveryRunnable
|
||||
import app.k9mail.core.common.mail.EmailAddress
|
||||
import app.k9mail.core.common.mail.toDomain
|
||||
import app.k9mail.core.common.net.toDomain
|
||||
import com.fsck.k9.helper.EmailHelper
|
||||
import com.fsck.k9.logging.Timber
|
||||
import java.io.IOException
|
||||
import okhttp3.HttpUrl
|
||||
|
@ -18,9 +18,7 @@ class AutoconfigDiscovery internal constructor(
|
|||
) : AutoDiscovery {
|
||||
|
||||
override fun initDiscovery(email: EmailAddress): List<AutoDiscoveryRunnable> {
|
||||
val domain = requireNotNull(EmailHelper.getDomainFromEmailAddress(email.address)?.toDomain()) {
|
||||
"Couldn't extract domain from email address: $email"
|
||||
}
|
||||
val domain = email.domain.toDomain()
|
||||
|
||||
val autoconfigUrls = urlProvider.getAutoconfigUrls(domain, email)
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import app.k9mail.autodiscovery.api.AutoDiscovery
|
|||
import app.k9mail.autodiscovery.api.AutoDiscoveryResult
|
||||
import app.k9mail.autodiscovery.api.AutoDiscoveryRunnable
|
||||
import app.k9mail.core.common.mail.EmailAddress
|
||||
import app.k9mail.core.common.mail.toDomain
|
||||
import app.k9mail.core.common.net.Domain
|
||||
import app.k9mail.core.common.net.toDomain
|
||||
import com.fsck.k9.helper.EmailHelper
|
||||
import com.fsck.k9.logging.Timber
|
||||
import java.io.IOException
|
||||
import okhttp3.HttpUrl
|
||||
|
@ -31,9 +31,7 @@ class MxLookupAutoconfigDiscovery internal constructor(
|
|||
|
||||
@Suppress("ReturnCount")
|
||||
private suspend fun mxLookupAutoconfig(email: EmailAddress): AutoDiscoveryResult? {
|
||||
val domain = requireNotNull(EmailHelper.getDomainFromEmailAddress(email.address)?.toDomain()) {
|
||||
"Couldn't extract domain from email address: ${email.address}"
|
||||
}
|
||||
val domain = email.domain.toDomain()
|
||||
|
||||
val mxHostName = mxLookup(domain) ?: return null
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import app.k9mail.core.common.net.Hostname
|
|||
import app.k9mail.core.common.net.Port
|
||||
import app.k9mail.core.common.net.toHostname
|
||||
import app.k9mail.core.common.net.toPort
|
||||
import com.fsck.k9.helper.EmailHelper
|
||||
import com.fsck.k9.logging.Timber
|
||||
import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
|
@ -37,7 +36,7 @@ private typealias ServerSettingsFactory<T> = (
|
|||
internal class RealAutoconfigParser : AutoconfigParser {
|
||||
override fun parseSettings(inputStream: InputStream, email: EmailAddress): AutoDiscoveryResult? {
|
||||
return try {
|
||||
ClientConfigParser(inputStream, email.address).parse()
|
||||
ClientConfigParser(inputStream, email).parse()
|
||||
} catch (e: XmlPullParserException) {
|
||||
throw AutoconfigParserException("Error parsing Autoconfig XML", e)
|
||||
}
|
||||
|
@ -47,10 +46,10 @@ internal class RealAutoconfigParser : AutoconfigParser {
|
|||
@Suppress("TooManyFunctions")
|
||||
private class ClientConfigParser(
|
||||
private val inputStream: InputStream,
|
||||
private val email: String,
|
||||
private val email: EmailAddress,
|
||||
) {
|
||||
private val localPart = requireNotNull(EmailHelper.getLocalPartFromEmailAddress(email)) { "Invalid email address" }
|
||||
private val domain = requireNotNull(EmailHelper.getDomainFromEmailAddress(email)) { "Invalid email address" }
|
||||
private val localPart = email.localPart
|
||||
private val domain = email.domain.normalized
|
||||
|
||||
private val pullParser: XmlPullParser = XmlPullParserFactory.newInstance().newPullParser().apply {
|
||||
setInput(InputStreamReader(inputStream))
|
||||
|
@ -288,7 +287,7 @@ private class ClientConfigParser(
|
|||
private fun String.replaceVariables(): String {
|
||||
return replace("%EMAILDOMAIN%", domain)
|
||||
.replace("%EMAILLOCALPART%", localPart)
|
||||
.replace("%EMAILADDRESS%", email)
|
||||
.replace("%EMAILADDRESS%", email.address)
|
||||
}
|
||||
|
||||
private fun createImapServerSettings(
|
||||
|
|
Loading…
Reference in a new issue