- Clone import: defer FurnitureData.json writes and append all entries in a single batched write instead of one read-modify-write per item, removing the main serialization bottleneck for large batches. - Clone import: raise SSE batch concurrency cap from 5 to 10 and bump the clone client/route default from 2 to 6. - Add a flush hook to runSseBatch so callers can batch deferred work before batch_complete is emitted, and surface flush errors as an error event. - Enable Next.js Cache Components (instant: false opt-out) and silence the related build warnings in next.config.ts. - Switch isomorphic-dompurify to dompurify and refresh dependencies.
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import { and, desc, eq, gt, or } from "drizzle-orm";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { ContentCard } from "@/components/public/ui";
|
|
import { auth } from "@/lib/auth";
|
|
import { unixNow } from "@/lib/bans";
|
|
import { Ban, db } from "@/lib/db";
|
|
|
|
// TODO: Cache Components adoption. Refactor this route so this opt-out can be removed.
|
|
// See: https://nextjs.org/docs/app/guides/migrating-to-cache-components
|
|
export const instant = false;
|
|
|
|
const FAR_FUTURE = Math.floor(Date.now() / 1000) + 50 * 365 * 24 * 3600;
|
|
|
|
export default async function BannedPage() {
|
|
const t = await getTranslations("pages.banned");
|
|
const session = await auth();
|
|
let reason = "";
|
|
let expire = 0;
|
|
let hasBan = false;
|
|
if (session?.user?.id) {
|
|
try {
|
|
const now = unixNow();
|
|
const [ban] = await db
|
|
.select({
|
|
banReason: Ban.banReason,
|
|
banExpire: Ban.banExpire,
|
|
})
|
|
.from(Ban)
|
|
.where(
|
|
and(
|
|
eq(Ban.userId, Number(session.user.id)),
|
|
or(eq(Ban.banExpire, 0), gt(Ban.banExpire, now)),
|
|
),
|
|
)
|
|
.orderBy(desc(Ban.timestamp))
|
|
.limit(1);
|
|
if (ban) {
|
|
hasBan = true;
|
|
reason = ban.banReason;
|
|
expire = ban.banExpire;
|
|
}
|
|
} catch {
|
|
// show generic message
|
|
}
|
|
}
|
|
|
|
const expiryText = !hasBan
|
|
? ""
|
|
: expire === 0 || expire > FAR_FUTURE
|
|
? t("permanent")
|
|
: t("expires", {
|
|
date: new Date(expire * 1000)
|
|
.toISOString()
|
|
.slice(0, 16)
|
|
.replace("T", " "),
|
|
});
|
|
|
|
return (
|
|
<main style={{ maxWidth: 560, margin: "2rem auto" }}>
|
|
<ContentCard icon="🚫" title={t("title")} subtitle={t("subtitle")}>
|
|
<p style={{ marginTop: 0 }}>{t("body")}</p>
|
|
{reason ? (
|
|
<p>
|
|
<strong>{t("reasonLabel")}</strong> {reason}
|
|
</p>
|
|
) : null}
|
|
{expiryText ? <p className="muted">{expiryText}</p> : null}
|
|
<p className="muted" style={{ marginBottom: 0 }}>
|
|
{t("contactStaff")}
|
|
</p>
|
|
</ContentCard>
|
|
</main>
|
|
);
|
|
}
|