Closed
Description
I'm trying to retrieve whether a subreddit is marked as NSFW to be able to remove them from a list (over18 == true
), but the value of getNsfw
seems to always be null
(and consequently, isNsfw
returns false
.)
fun main(args: Array<String>) {
val credentials = Credentials.userless(clientId, clientSecret, uuid)
val client = OAuthHelper.automatic(OkHttpNetworkAdapter(userAgent), credentials)
val sub = client.subreddit("nsfw").about()
println(sub.nsfw) // null
println(sub.isNsfw) // false
}
Testing this with an SFW subreddit (i.e. r/Otters
) also results in getNsfw
returning null
.
Note: Viewing about
at r/nsfw/about.json
reveals:
which is interesting, since both NSFW flags are annotated with over_18
and not over18
.
Edit 2: Just to make sure it wasn't an inconsistency between the OAuth APIs and the user-accessible API, I logged the response body in an interceptor:
val ohClient = OkHttpClient.Builder()
.addInterceptor {
val res = it.proceed(it.request())
res.body()?.source()?.let {
it.request(Long.MAX_VALUE)
println(it.buffer().clone().readString(Charsets.UTF_8))
}
res
}
.build()
client = OAuthHelper.automatic(OkHttpNetworkAdapter(userAgent, ohClient), credentials))
and it seems to be the same.