Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Adjust the messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
K1rakishou committed Feb 3, 2024
1 parent 41c6123 commit 3d4fcd8
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ class Chan4CaptchaLayoutViewModel : BaseViewModel() {
is CaptchaThreadRateLimitError -> {
_captchaInfoToShow.value = AsyncData.Error(CaptchaThreadRateLimitError(remainingCooldownMs))
}
is CaptchaPostRateLimitError -> {
_captchaInfoToShow.value = AsyncData.Error(CaptchaPostRateLimitError(remainingCooldownMs))
}
else -> {
break
}
Expand Down Expand Up @@ -391,8 +394,19 @@ class Chan4CaptchaLayoutViewModel : BaseViewModel() {

val cooldownMs = captchaInfoRaw.pcd.times(1000L)

Logger.d(TAG, "requestCaptchaInternal($chanDescriptor) new thread creation rate limited! cooldownMs=$cooldownMs")
throw CaptchaThreadRateLimitError(cooldownMs)
when (chanDescriptor) {
is ChanDescriptor.CompositeCatalogDescriptor -> {
error("Cannot use CompositeCatalogDescriptor here")
}
is ChanDescriptor.CatalogDescriptor -> {
Logger.d(TAG, "requestCaptchaInternal($chanDescriptor) new thread creation rate limited! cooldownMs=$cooldownMs")
throw CaptchaThreadRateLimitError(cooldownMs)
}
is ChanDescriptor.ThreadDescriptor -> {
Logger.d(TAG, "requestCaptchaInternal($chanDescriptor) new post creation rate limited! cooldownMs=$cooldownMs")
throw CaptchaPostRateLimitError(cooldownMs)
}
}
}

if (captchaInfoRaw.isNoopChallenge()) {
Expand Down Expand Up @@ -688,6 +702,10 @@ class Chan4CaptchaLayoutViewModel : BaseViewModel() {
Exception("4chan captcha rate-limit detected!\nPlease wait ${cooldownMs / 1000L} seconds before making a thread."),
CaptchaCooldownError

class CaptchaPostRateLimitError(override val cooldownMs: Long) :
Exception("4chan captcha rate-limit detected!\nPlease wait ${cooldownMs / 1000L} seconds before making a post."),
CaptchaCooldownError

class UnknownCaptchaError(message: String) : java.lang.Exception(message)

companion object {
Expand Down

0 comments on commit 3d4fcd8

Please sign in to comment.