diff --git a/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt b/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt index 3ac273a..fa965d1 100644 --- a/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt +++ b/src/main/kotlin/net/thauvin/erik/akismet/Akismet.kt @@ -83,6 +83,15 @@ open class Akismet(apiKey: String) { var httpStatusCode: Int = 0 private set + /** + * The actual response sent by Aksimet from the last operation. + * + * For example: ```true```, ```false```, ```valid```, ```invalid```, etc. + */ + @Suppress("MemberVisibilityCanBePrivate") + var response: String = "" + private set + /** * The X-akismet-pro-tip header from the last operation, if any. */ @@ -90,6 +99,15 @@ open class Akismet(apiKey: String) { var proTip: String = "" private set + /** + * 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. Read more about this feature in this + * [Akismet blog post](https://blog.akismet.com/2014/04/23/theres-a-ninja-in-your-akismet/). + */ + @Suppress("MemberVisibilityCanBePrivate") + var isDiscard: Boolean = false + private set + /** * The X-akismet-error header from the last operation, if any. */ @@ -156,9 +174,7 @@ open class Akismet(apiKey: String) { * Submit Spam (missed spam). * See the [Akismet API](https://akismet.com/development/api/#submit-spam) for more details. */ - fun submitSpam( - comment: AkismetComment - ): Boolean { + fun submitSpam(comment: AkismetComment): Boolean { return executeMethod(buildApiUrl("submit-spam"), buildFormBody(comment)) } @@ -167,9 +183,7 @@ open class Akismet(apiKey: String) { * See the [Akismet API](https://akismet.com/development/api/#submit-ham) for more details. */ - fun submitHam( - comment: AkismetComment - ): Boolean { + fun submitHam(comment: AkismetComment): Boolean { return executeMethod(buildApiUrl("submit-ham"), buildFormBody(comment)) } @@ -205,11 +219,12 @@ open class Akismet(apiKey: String) { val result = client.newCall(request).execute() httpStatusCode = result.code proTip = result.header("x-akismet-pro-tip", "").toString() + isDiscard = proTip.equals("discard", true) error = result.header("x-akismet-error", "").toString() debugHelp = result.header("x-akismet-debug-help", "").toString() val body = result.body?.string() if (body != null) { - val response = body.trim() + response = body.trim() if (response.equals("valid", true) || response.equals("true", true) || response.startsWith("Thanks", true)) { diff --git a/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt b/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt index f0c37cc..e027a3d 100644 --- a/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt +++ b/src/main/kotlin/net/thauvin/erik/akismet/AkismetComment.kt @@ -124,10 +124,11 @@ open class AkismetComment() { var recheckReason: String = "" /** * In PHP, there is an array of environmental variables called $_SERVER that contains information about the Web - * server itself as well as a key/value for every HTTP header sent with the request. - * - * This data is highly useful to Akismet. How the submitted content interacts with the server can be very telling, - * so please include as much of it as possible. + * server itself as well as a key/value for every HTTP header sent with the request.This data is highly useful to + * Akismet. + * + * How the submitted content interacts with the server can be very telling, so please include as much of it as + * ossible. */ var other: Map = emptyMap()