From a59668f46cb13ee68881e1339cd4aa18d0d9b098 Mon Sep 17 00:00:00 2001 From: blackvid <144696265+blackvid@users.noreply.github.com> Date: Wed, 20 Dec 2023 15:48:06 -0400 Subject: [PATCH 01/11] Important update --- src/components/utils/Lightbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/utils/Lightbar.tsx b/src/components/utils/Lightbar.tsx index 06eea927..f15f84ea 100644 --- a/src/components/utils/Lightbar.tsx +++ b/src/components/utils/Lightbar.tsx @@ -160,7 +160,7 @@ function ParticlesCanvas() { } // Fish easter egg - const shouldShowFishie = Math.floor(Math.random() * 600) === 1; + const shouldShowFishie = Math.floor(Math.random() * 600) === 69; if (shouldShowFishie) { imageOverride = [ { From 82d25169519d9e8e80a0c5e853d41f979a7fa0fa Mon Sep 17 00:00:00 2001 From: mrjvs Date: Thu, 21 Dec 2023 20:39:53 +0100 Subject: [PATCH 02/11] Report captcha solves --- src/backend/helpers/report.ts | 12 +++++++++++- src/stores/turnstile/index.tsx | 12 ++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/backend/helpers/report.ts b/src/backend/helpers/report.ts index b7c32645..1150c22d 100644 --- a/src/backend/helpers/report.ts +++ b/src/backend/helpers/report.ts @@ -9,6 +9,7 @@ import { PlayerMeta } from "@/stores/player/slices/source"; // for anybody who cares - these are anonymous metrics. // They are just used for figuring out if providers are broken or not const metricsEndpoint = "https://backend.movie-web.app/metrics/providers"; +const captchaMetricsEndpoint = "https://backend.movie-web.app/metrics/captcha"; const batchId = () => nanoid(32); export type ProviderMetric = { @@ -136,8 +137,17 @@ export function scrapePartsToProviderMetric( export function useReportProviders() { const report = useCallback((items: ProviderMetric[]) => { if (items.length === 0) return; - reportProviders(items); + reportProviders(items).catch(() => {}); }, []); return { report }; } + +export function reportCaptchaSolve(success: boolean) { + ofetch(captchaMetricsEndpoint, { + method: "POST", + body: { + success, + }, + }).catch(() => {}); +} diff --git a/src/stores/turnstile/index.tsx b/src/stores/turnstile/index.tsx index 907ffc2e..0d7727f6 100644 --- a/src/stores/turnstile/index.tsx +++ b/src/stores/turnstile/index.tsx @@ -2,6 +2,7 @@ import Turnstile, { BoundTurnstileObject } from "react-turnstile"; import { create } from "zustand"; import { immer } from "zustand/middleware/immer"; +import { reportCaptchaSolve } from "@/backend/helpers/report"; import { conf } from "@/setup/config"; export interface TurnstileStore { @@ -52,11 +53,18 @@ export function isTurnstileInitialized() { return !!getTurnstile(); } -export function getTurnstileToken() { +export async function getTurnstileToken() { const turnstile = getTurnstile(); turnstile?.reset(); turnstile?.execute(); - return useTurnstileStore.getState().getToken(); + try { + const token = await useTurnstileStore.getState().getToken(); + reportCaptchaSolve(true); + return token; + } catch (err) { + reportCaptchaSolve(false); + throw err; + } } export function TurnstileProvider() { From 75af3b992d6feb08c2a41377e5cb5e97c632d2a0 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Thu, 21 Dec 2023 20:47:38 +0100 Subject: [PATCH 03/11] Made some more keys translatable --- src/assets/locales/en.json | 1 + src/components/form/PassphraseDisplay.tsx | 4 +++- src/pages/Settings.tsx | 2 +- src/pages/parts/settings/SidebarPart.tsx | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 6c6c3e9c..042cbe91 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -25,6 +25,7 @@ }, "generate": { "title": "Your passphrase", + "passphraseFrameLabel": "Passphrase", "next": "I have saved my passphrase", "description": "Your passphrase acts as your username and password. Make sure to keep it safe as you will need to enter it to login to your account" }, diff --git a/src/components/form/PassphraseDisplay.tsx b/src/components/form/PassphraseDisplay.tsx index 8eb4a2b9..92918373 100644 --- a/src/components/form/PassphraseDisplay.tsx +++ b/src/components/form/PassphraseDisplay.tsx @@ -25,7 +25,9 @@ export function PassphraseDisplay(props: { mnemonic: string }) { return (
-

Passphrase

+

+ {t("auth.generate.passphraseFrameLabel")} +