Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
chore: fix some null errors in /v2/sponsors/{login}
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Mar 18, 2022
1 parent 65393b0 commit 2738c64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ plugins {
apply(plugin = "kotlinx-atomicfu")

val JAVA_VERSION = JavaVersion.VERSION_17
val VERSION = Version(4, 0, 3, 0, ReleaseType.None)
val VERSION = Version(4, 0, 4, 0, ReleaseType.None)

val commitHash by lazy {
val cmd = "git rev-parse --short HEAD".split("\\s".toRegex())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,6 @@ class FetchSponsorV2Endpoint(private val config: HanaConfig, private val httpCli
val sponsoring = data["data"]!!.jsonObject["user"]!!.jsonObject["sponsorshipsAsSponsor"]!!.jsonObject
val sponsors = data["data"]!!.jsonObject["user"]!!.jsonObject["sponsorshipsAsMaintainer"]!!.jsonObject

println(sponsoring)

call.respond(
HttpStatusCode.OK,
buildJsonObject {
Expand Down Expand Up @@ -296,18 +294,18 @@ class FetchSponsorV2Endpoint(private val config: HanaConfig, private val httpCli
put(
"price",
if (pricing == "Dollars") {
tier["monthlyPriceInDollars"]!!
tier["monthlyPriceInDollars"] ?: JsonNull
} else {
tier["monthlyPriceInCents"]!!
tier["monthlyPriceInCents"] ?: JsonNull
}
)
}
)

val sponsorEntity = obj["sponsorEntity"]!!.jsonObject

put("followers", sponsorEntity["following"]!!)
put("followers", sponsorEntity["followers"]!!)
put("followers", sponsorEntity["following"]!!.jsonObject["totalCount"]!!.jsonPrimitive.int)
put("followers", sponsorEntity["followers"]!!.jsonObject["totalCount"]!!.jsonPrimitive.int)

val status = try {
sponsorEntity["status"]?.jsonObject
Expand All @@ -319,8 +317,8 @@ class FetchSponsorV2Endpoint(private val config: HanaConfig, private val httpCli
put(
"status",
buildJsonObject {
put("emoji", status["emojiHTML"]!!)
put("message", status["message"]!!)
put("emoji", status["emojiHTML"]?.jsonPrimitive?.contentOrNull)
put("message", status["message"]?.jsonPrimitive?.contentOrNull)
put("expires_at", status["expiresAt"]?.jsonPrimitive?.content)
}
)
Expand Down

0 comments on commit 2738c64

Please sign in to comment.