Cleanup.
This commit is contained in:
parent
3ce2bac9c7
commit
b674549840
5 changed files with 61 additions and 44 deletions
|
@ -52,13 +52,13 @@ import java.util.logging.Logger
|
|||
/**
|
||||
* Provides access to the [Akismet API](https://akismet.com/development/api/).
|
||||
*
|
||||
* @constructor Creates new instance using the provided [Akismet](https://www.askimet.com/) API key.
|
||||
* @constructor Creates a new instance using the provided [Akismet](https://www.askimet.com/) API key.
|
||||
*/
|
||||
@Version(properties = "version.properties", type = "kt")
|
||||
open class Akismet(apiKey: String) {
|
||||
companion object {
|
||||
/**
|
||||
* (Re)Create a [comment][AkismetComment] from a JSON string.
|
||||
* (Re)Creates a [comment][AkismetComment] from a JSON string.
|
||||
*
|
||||
* @see [AkismetComment.toString]
|
||||
*/
|
||||
|
@ -68,7 +68,7 @@ open class Akismet(apiKey: String) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert a date to a UTC timestamp. (ISO 8601)
|
||||
* Converts a date to a UTC timestamp. (ISO 8601)
|
||||
*
|
||||
* @see [AkismetComment.dateGmt]
|
||||
* @see [AkismetComment.postModifiedGmt]
|
||||
|
@ -81,7 +81,7 @@ open class Akismet(apiKey: String) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Convert a locale date/time to a UTC timestamp. (ISO 8601)
|
||||
* Converts a locale date/time to a UTC timestamp. (ISO 8601)
|
||||
*
|
||||
* @see [AkismetComment.dateGmt]
|
||||
* @see [AkismetComment.postModifiedGmt]
|
||||
|
@ -125,7 +125,7 @@ open class Akismet(apiKey: String) {
|
|||
var appUserAgent = ""
|
||||
|
||||
/**
|
||||
* Check if the API Key has been verified
|
||||
* Set to `true` if the API Key has been verified.
|
||||
*
|
||||
* @see [Akismet.verifyKey]
|
||||
*/
|
||||
|
@ -173,7 +173,7 @@ open class Akismet(apiKey: String) {
|
|||
private set
|
||||
|
||||
/**
|
||||
* Set to true if Akismet has determined that the last [checked comment][checkComment] is blatant spam, and you
|
||||
* Set to `true` if Akismet has determined that the last [checked comment][checkComment] is blatant spam, and you
|
||||
* can safely discard it without saving it in any spam queue.
|
||||
*
|
||||
* See the [Akismet API](https://akismet.com/development/api/#comment-check) for more details.
|
||||
|
@ -226,7 +226,7 @@ open class Akismet(apiKey: String) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Create a new instance using an [Akismet](https://www.askimet.com/) API key and URL registered with Akismet.
|
||||
* Creates a new instance using an [Akismet](https://www.askimet.com/) API key and URL registered with Akismet.
|
||||
*/
|
||||
constructor(apiKey: String, blog: String) : this(apiKey) {
|
||||
this.blog = blog
|
||||
|
@ -318,7 +318,7 @@ open class Akismet(apiKey: String) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Execute a call to an Akismet REST API method.
|
||||
* Executes a call to an Akismet REST API method.
|
||||
*
|
||||
* @param apiUrl The Akismet API URL endpoint. (e.g. https://rest.akismet.com/1.1/verify-key)
|
||||
* @param formBody The HTTP POST form body containing the request parameters to be submitted.
|
||||
|
@ -371,7 +371,7 @@ open class Akismet(apiKey: String) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reset the [debugHelp], [errorMessage], [httpStatusCode], [isDiscard], [isVerifiedKey], [proTip], and
|
||||
* Resets the [debugHelp], [errorMessage], [httpStatusCode], [isDiscard], [isVerifiedKey], [proTip], and
|
||||
* [response] properties.
|
||||
*/
|
||||
fun reset() {
|
||||
|
|
|
@ -36,7 +36,6 @@ import kotlinx.serialization.Serializable
|
|||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import javax.servlet.http.HttpServletRequest
|
||||
import kotlin.collections.HashMap
|
||||
import kotlin.collections.Map
|
||||
import kotlin.collections.emptyMap
|
||||
import kotlin.collections.iterator
|
||||
|
@ -53,7 +52,7 @@ private fun String?.ifNull() = this ?: ""
|
|||
*
|
||||
* See the [Akismet API](https://akismet.com/development/api/#comment-check) for more details.
|
||||
*
|
||||
* @constructor Create an Akismet comment instance.
|
||||
* @constructor Creates a new [AskimetComment] instance.
|
||||
*
|
||||
* See the [Akismet API](https://akismet.com/development/api/#comment-check) for more details.
|
||||
*
|
||||
|
@ -233,7 +232,7 @@ open class AkismetComment(val userIp: String, val userAgent: String) {
|
|||
var serverEnv: Map<String, String> = emptyMap()
|
||||
|
||||
/**
|
||||
* Create an Akismet comment extracting the [userIp], [userAgent], [referrer] and [serverEnv] environment variables
|
||||
* Creates a new instance extracting the [userIp], [userAgent], [referrer] and [serverEnv] environment variables
|
||||
* from a Servlet request.
|
||||
*
|
||||
* See the
|
||||
|
@ -242,8 +241,8 @@ open class AkismetComment(val userIp: String, val userAgent: String) {
|
|||
* @see [serverEnv]
|
||||
*/
|
||||
constructor(request: HttpServletRequest) : this(
|
||||
request.remoteAddr,
|
||||
request.getHeader("User-Agent").ifNull()
|
||||
request.remoteAddr,
|
||||
request.getHeader("User-Agent").ifNull()
|
||||
) {
|
||||
referrer = request.getHeader("referer").ifNull()
|
||||
serverEnv = buildServerEnv(request)
|
||||
|
@ -325,7 +324,7 @@ open class AkismetComment(val userIp: String, val userAgent: String) {
|
|||
}
|
||||
|
||||
private fun buildServerEnv(request: HttpServletRequest): Map<String, String> {
|
||||
val params = HashMap<String, String>()
|
||||
val params = mutableMapOf<String, String>()
|
||||
|
||||
params["REMOTE_ADDR"] = request.remoteAddr
|
||||
params["REQUEST_URI"] = request.requestURI
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue