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