Additional checks for listed and approve in fetching release date (KT-30388)

This commit is contained in:
Nikolay Krasko
2019-03-22 17:59:00 +03:00
parent 27397f4131
commit 0c2bdc68f1
@@ -336,6 +336,11 @@ class KotlinPluginUpdater(private val propertiesComponent: PropertiesComponent)
private class PluginDTO {
var cdate: String? = null
var channel: String? = null
// `true` if the version is seen in plugin site and available for download.
// Maybe be `false` if author requested version deletion.
var listed: Boolean = true
// `true` if version is approved and verified
var approve: Boolean = true
}
@Throws(IOException::class, ResponseParseException::class)
@@ -352,7 +357,10 @@ class KotlinPluginUpdater(private val propertiesComponent: PropertiesComponent)
throw ResponseParseException("Can't parse json response", syntaxException)
}
val selectedPluginDTO = pluginDTOs.singleOrNull { it.channel == channel || (it.channel == "" && channel == null) }
val selectedPluginDTO = pluginDTOs
.firstOrNull {
it.listed && it.approve && (it.channel == channel || (it.channel == "" && channel == null))
}
?: return null
val dateString = selectedPluginDTO.cdate ?: throw ResponseParseException("Empty cdate")