Fix User Agent block error not showing at Tsuki (#8381)
* Fix UA error not showing at Tsuki. * Add missing HTTP code in if.
This commit is contained in:
parent
94915eeb0f
commit
0fb6bc0d44
|
@ -6,7 +6,7 @@ ext {
|
||||||
extName = 'Tsuki Mangás'
|
extName = 'Tsuki Mangás'
|
||||||
pkgNameSuffix = 'pt.tsukimangas'
|
pkgNameSuffix = 'pt.tsukimangas'
|
||||||
extClass = '.TsukiMangas'
|
extClass = '.TsukiMangas'
|
||||||
extVersionCode = 23
|
extVersionCode = 24
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
containsNsfw = true
|
containsNsfw = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,6 +375,12 @@ class TsukiMangas : HttpSource(), ConfigurableSource {
|
||||||
throw IOException(ERROR_CANNOT_LOGIN)
|
throw IOException(ERROR_CANNOT_LOGIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// API returns 403 or 1020 when User-Agent permission is disabled.
|
||||||
|
if (loginResponse.code == 403 || loginResponse.code == 1020) {
|
||||||
|
loginResponse.close()
|
||||||
|
throw IOException(UA_DISABLED_MESSAGE)
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val loginResponseBody = loginResponse.body?.string().orEmpty()
|
val loginResponseBody = loginResponse.body?.string().orEmpty()
|
||||||
val authResult = json.decodeFromString<TsukiAuthResultDto>(loginResponseBody)
|
val authResult = json.decodeFromString<TsukiAuthResultDto>(loginResponseBody)
|
||||||
|
@ -394,11 +400,10 @@ class TsukiMangas : HttpSource(), ConfigurableSource {
|
||||||
|
|
||||||
val response = chain.proceed(authorizedRequest)
|
val response = chain.proceed(authorizedRequest)
|
||||||
|
|
||||||
// API returns 403 when User-Agent permission is disabled
|
// API returns 401 when the token is invalid.
|
||||||
// and returns 401 when the token is invalid.
|
if (response.code == 401) {
|
||||||
if (response.code == 403 || response.code == 401) {
|
|
||||||
response.close()
|
response.close()
|
||||||
throw IOException(if (response.code == 403) UA_DISABLED_MESSAGE else ERROR_INVALID_TOKEN)
|
throw IOException(ERROR_INVALID_TOKEN)
|
||||||
}
|
}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
Loading…
Reference in New Issue