web/DownloadButton: show a message about ongoing antibot check

This commit is contained in:
wukko 2024-09-20 15:20:53 +06:00
parent c99240339d
commit c0bb637480
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 14 additions and 0 deletions

View file

@ -8,6 +8,8 @@
"tunnel.probe": "couldn't verify whether you can download this file. try again in a few seconds!",
"captcha_ongoing": "still checking if you're not a bot. wait for the spinner to disappear and try again.\n\nif it takes too long, please let us know! we use cloudflare turnstile for bot protection and sometimes it blocks people for no reason.",
"api.auth.jwt.missing": "couldn't confirm whether you're not a robot because the processing server didn't receive the human access token. try again in a few seconds or reload the page!",
"api.auth.jwt.invalid": "couldn't confirm whether you're not a robot because your human access token expired and wasn't renewed. try again in a few seconds or reload the page!",
"api.auth.turnstile.missing": "couldn't confirm whether you're not a robot because the processing server didn't receive the human access token. try again in a few seconds or reload the page!",

View file

@ -6,6 +6,9 @@
import { createDialog } from "$lib/dialogs";
import { downloadFile } from "$lib/download";
import { cachedInfo } from "$lib/api/server-info";
import { turnstileLoaded } from "$lib/state/turnstile";
import type { DialogInfo } from "$lib/types/dialog";
export let url: string;
@ -63,6 +66,15 @@
export const download = async (link: string) => {
changeDownloadButton("think");
if ($cachedInfo?.info?.cobalt?.turnstileSitekey && !$turnstileLoaded) {
changeDownloadButton("error");
return createDialog({
...defaultErrorPopup,
bodyText: $t("error.captcha_ongoing"),
});
}
const response = await API.request(link);
if (!response) {