Send and receive SMS messages using your Android phone programmatically via a simple HTTP API
Fix captcha
Acho Arnold Ewin4cb9013fe1ad
diff --git a/web/app/pages/search-messages/index.vue b/web/app/pages/search-messages/index.vueindex 401768b8..e71dcbf6 100644--- a/web/app/pages/search-messages/index.vue+++ b/web/app/pages/search-messages/index.vue@@ -28,6 +28,8 @@ interface Turnstile {"error-callback"?: (error: string) => void;},): string | null | undefined;+ reset(widgetId?: string): void;+ remove(widgetId?: string): void;}definePageMeta({@@ -63,6 +65,8 @@ const formQuery = ref("");const messages = ref<EntitiesMessage[]>([]);const totalMessages = ref(0);const selectedIds = ref<string[]>([]);+let turnstileWidgetId: string | null = null;+let captchaPromise: Promise<string> | null = null;const page = ref(1);const itemsPerPage = ref(100);@@ -123,23 +127,51 @@ const messageStatusSelectItems = [];function getCaptcha(): Promise<string> {- return new Promise<string>((resolve, reject) => {+ if (captchaPromise) {+ return captchaPromise;+ }++ captchaPromise = new Promise<string>((resolve, reject) => {const turnstile = (window as unknown as { turnstile?: Turnstile }).turnstile;if (!turnstile) {resolve("");return;}++ const resetPromise = () => {+ captchaPromise = null;+ };+turnstile.ready(() => {- turnstile.render("#cloudflare-turnstile", {- sitekey: (config.public as Record<string, string>)- .cloudflareTurnstileSiteKey!,- action: "search_messages",- callback: (token) => resolve(token),- "error-callback": (error: string) => reject(error),- });+ const complete = (token: string) => {+ resetPromise();+ resolve(token);+ };+ const fail = (error: string) => {+ resetPromise();+ reject(error);+ };++ if (turnstileWidgetId) {+ turnstile.reset(turnstileWidgetId);+ return;+ }++ turnstileWidgetId =+ turnstile.render("#cloudflare-turnstile", {+ sitekey: (config.public as Record<string, string>)+ .cloudflareTurnstileSiteKey!,+ action: "search_messages",+ callback: complete,+ "error-callback": fail,+ }) ?? null;});});++ return captchaPromise.finally(() => {+ captchaPromise = null;+ });}function parseErrors(error: any): ErrorMessages {@@ -329,6 +361,15 @@ onMounted(async () => {await fetchMessages(true);}});++onBeforeUnmount(() => {+ const turnstile = (window as unknown as { turnstile?: Turnstile })+ .turnstile;+ if (turnstile && turnstileWidgetId) {+ turnstile.remove(turnstileWidgetId);+ turnstileWidgetId = null;+ }+});</script><template>diff --git a/web/package.json b/web/package.jsonindex bdd46fa6..6766eb47 100644--- a/web/package.json+++ b/web/package.json@@ -25,6 +25,7 @@"moment": "^2.30.1","nuxt": "^4.4.6","pinia": "^3.0.4",+ "prettier": "^3.8.4","pusher-js": "^8.5.0","qrcode": "^1.5.4","sass": "^1.100.0",diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yamlindex d803eac3..ab3bdb6b 100644--- a/web/pnpm-lock.yaml+++ b/web/pnpm-lock.yaml@@ -47,6 +47,9 @@ importers:pinia:specifier: ^3.0.4version: 3.0.4([email protected])+ prettier:+ specifier: ^3.8.4+ version: 3.8.4pusher-js:specifier: ^8.5.0version: 8.5.0@@ -3458,6 +3461,11 @@ packages:resolution: {integrity: sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==}engines: {node: '>=20'}+ resolution: {integrity: sha512-N2MylSdi48+5N/6S5j+maeHbUSIzzZ5uOcX5Hm4QpV8Dkb1HFjfAKTKX6yNPJQD9AhcT3ifHNB66tWTTJDi11Q==}+ engines: {node: '>=14'}+ hasBin: true+resolution: {integrity: sha512-nODzvTiYVRGRqAOvE84Vk5JDPyyxsVk0/fbA/bq7RqlnhksGpset09XTxbpvLTIjoaF7K8Z8DG8yHtKGTPSYRw==}engines: {node: '>=20'}@@ -7841,6 +7849,8 @@ snapshots:+ [email protected]: {}+