This commit is contained in:
@@ -11,3 +11,4 @@ docker-compose.yml
|
|||||||
nginx
|
nginx
|
||||||
test-results
|
test-results
|
||||||
playwright-report
|
playwright-report
|
||||||
|
dist
|
||||||
@@ -34,6 +34,8 @@ GEMINI_TTS_API_KEY=YOUR_GEMINI_TTS_API_KEY
|
|||||||
TMN_DEST_PHONE_NUM=YOUR_TMN_DEST_PHONE_NUM
|
TMN_DEST_PHONE_NUM=YOUR_TMN_DEST_PHONE_NUM
|
||||||
# api.sastify.xyz Private API key
|
# api.sastify.xyz Private API key
|
||||||
SASTIFY_API_PRIVKEY=YOUR_SASTIFY_API_PRIVKEY
|
SASTIFY_API_PRIVKEY=YOUR_SASTIFY_API_PRIVKEY
|
||||||
|
# Widget key
|
||||||
|
DONATE_WIDGET_KEY=RANDOM_GENERATED
|
||||||
|
|
||||||
# Environment
|
# Environment
|
||||||
ENVIRONMENT=production
|
ENVIRONMENT=production
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { DonateAdminPage } from "./client";
|
import { DonateAdminPage } from "./client";
|
||||||
import { donations } from "@/lib/db/schema";
|
import { donations } from "@/lib/db/schema";
|
||||||
import { desc } from "drizzle-orm";
|
import { desc, getTableColumns, sql } from "drizzle-orm";
|
||||||
import { adminCheck } from "@/lib/auth";
|
import { adminCheck } from "@/lib/auth";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ export default async function () {
|
|||||||
redirect(`/login?next=${encodeURIComponent("/donate/admin")}`);
|
redirect(`/login?next=${encodeURIComponent("/donate/admin")}`);
|
||||||
|
|
||||||
const data = await db
|
const data = await db
|
||||||
.select()
|
.select({ ...getTableColumns(donations), image: sql<Buffer>`NULL` })
|
||||||
.from(donations)
|
.from(donations)
|
||||||
.limit(100)
|
.limit(100)
|
||||||
.orderBy(desc(donations.id));
|
.orderBy(desc(donations.id));
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import z from "zod";
|
|||||||
import { env } from "process";
|
import { env } from "process";
|
||||||
import { redis } from "@/lib/db/redis";
|
import { redis } from "@/lib/db/redis";
|
||||||
import { hash } from "bun";
|
import { hash } from "bun";
|
||||||
|
const { DONATE_WIDGET_KEY } = process.env as Record<string, string>;
|
||||||
|
|
||||||
const Schema = z.object({
|
const Schema = z.object({
|
||||||
message: z.string().max(1000),
|
message: z.string().max(1000),
|
||||||
|
key: z.literal(DONATE_WIDGET_KEY),
|
||||||
});
|
});
|
||||||
|
|
||||||
const voices = ["Zephyr", "Charon", "Fenrir", "Kore", "Sulafat"];
|
const voices = ["Zephyr", "Charon", "Fenrir", "Kore", "Sulafat"];
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { cn } from "@/lib/utils";
|
|||||||
import { sse } from "@/lib/db/sse-endpoints";
|
import { sse } from "@/lib/db/sse-endpoints";
|
||||||
import DefaultImage from "#/favicon.webp";
|
import DefaultImage from "#/favicon.webp";
|
||||||
import { markDone, markRunning } from "./api";
|
import { markDone, markRunning } from "./api";
|
||||||
|
import { useSearchParams } from "next/navigation";
|
||||||
|
|
||||||
type DonateData = {
|
type DonateData = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -23,6 +24,7 @@ export default function () {
|
|||||||
const sfx = useRef<HTMLAudioElement | null>(null);
|
const sfx = useRef<HTMLAudioElement | null>(null);
|
||||||
const onQueue = useRef<string[]>([]);
|
const onQueue = useRef<string[]>([]);
|
||||||
const queue = useRef<Promise<void>>(Promise.resolve());
|
const queue = useRef<Promise<void>>(Promise.resolve());
|
||||||
|
const sp = useSearchParams();
|
||||||
|
|
||||||
function enqueue(data: DonateData) {
|
function enqueue(data: DonateData) {
|
||||||
if (onQueue.current.includes(data.id)) return;
|
if (onQueue.current.includes(data.id)) return;
|
||||||
@@ -36,7 +38,7 @@ export default function () {
|
|||||||
markRunning(data.id);
|
markRunning(data.id);
|
||||||
console.log("Requesting TTS");
|
console.log("Requesting TTS");
|
||||||
const tts = new Audio(
|
const tts = new Audio(
|
||||||
`/api/tts?message=${encodeURIComponent(`"${name} โดเนทมา ${amount} บาท.. ${message}"`)}`,
|
`/api/tts?message=${encodeURIComponent(`"${name} โดเนทมา ${amount} บาท.. ${message}"`)}&key=${sp.get("key")}`,
|
||||||
);
|
);
|
||||||
tts.load();
|
tts.load();
|
||||||
console.log("Waiting for response");
|
console.log("Waiting for response");
|
||||||
|
|||||||
Reference in New Issue
Block a user