mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-05-13 13:17:45 +00:00
feat: add miis with alleged inappropriate images to queue
This commit is contained in:
parent
bf8e8a094d
commit
975d55bd19
3 changed files with 17 additions and 15 deletions
|
|
@ -153,6 +153,7 @@ export async function POST(request: NextRequest) {
|
||||||
const description = uncensoredDescription && profanity.censor(uncensoredDescription);
|
const description = uncensoredDescription && profanity.censor(uncensoredDescription);
|
||||||
|
|
||||||
// Validate image files
|
// Validate image files
|
||||||
|
let wasImagesModerated = false;
|
||||||
const customImages: File[] = [];
|
const customImages: File[] = [];
|
||||||
|
|
||||||
for (const img of [image1, image2, image3]) {
|
for (const img of [image1, image2, image3]) {
|
||||||
|
|
@ -162,7 +163,7 @@ export async function POST(request: NextRequest) {
|
||||||
if (imageValidation.valid) {
|
if (imageValidation.valid) {
|
||||||
customImages.push(img);
|
customImages.push(img);
|
||||||
} else {
|
} else {
|
||||||
return rateLimit.sendResponse({ error: `Failed to verify custom image: ${imageValidation.error}` }, imageValidation.status ?? 400);
|
wasImagesModerated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,10 +171,8 @@ export async function POST(request: NextRequest) {
|
||||||
if (platform === "SWITCH") {
|
if (platform === "SWITCH") {
|
||||||
const portraitValidation = await validateImage(miiPortraitImage);
|
const portraitValidation = await validateImage(miiPortraitImage);
|
||||||
const featuresValidation = await validateImage(miiFeaturesImage);
|
const featuresValidation = await validateImage(miiFeaturesImage);
|
||||||
if (!portraitValidation.valid)
|
if (!portraitValidation.valid) wasImagesModerated = true;
|
||||||
return rateLimit.sendResponse({ error: `Failed to verify portrait: ${portraitValidation.error}` }, portraitValidation.status ?? 400);
|
if (!featuresValidation.valid) wasImagesModerated = true;
|
||||||
if (!featuresValidation.valid)
|
|
||||||
return rateLimit.sendResponse({ error: `Failed to verify features: ${featuresValidation.error}` }, featuresValidation.status ?? 400);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const qrBytes = new Uint8Array(qrBytesRaw ?? []);
|
const qrBytes = new Uint8Array(qrBytesRaw ?? []);
|
||||||
|
|
@ -198,7 +197,7 @@ export async function POST(request: NextRequest) {
|
||||||
tags,
|
tags,
|
||||||
description,
|
description,
|
||||||
gender: gender ?? "MALE",
|
gender: gender ?? "MALE",
|
||||||
in_queue: settings.queueEnabled,
|
in_queue: wasImagesModerated || settings.queueEnabled,
|
||||||
|
|
||||||
// Automatically detect certain information if on 3DS
|
// Automatically detect certain information if on 3DS
|
||||||
...(platform === "THREE_DS"
|
...(platform === "THREE_DS"
|
||||||
|
|
@ -335,5 +334,5 @@ export async function POST(request: NextRequest) {
|
||||||
return rateLimit.sendResponse({ error: "Failed to store user images" }, 500);
|
return rateLimit.sendResponse({ error: "Failed to store user images" }, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rateLimit.sendResponse({ success: true, id: miiRecord.id });
|
return rateLimit.sendResponse({ success: true, id: miiRecord.id, inQueue: wasImagesModerated });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import Description from "@/components/description";
|
||||||
import MiiInstructions from "@/components/mii/instructions";
|
import MiiInstructions from "@/components/mii/instructions";
|
||||||
|
|
||||||
import { SwitchMiiInstructions } from "@/types";
|
import { SwitchMiiInstructions } from "@/types";
|
||||||
|
import { settings } from "@/lib/settings";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
params: Promise<{ id: string }>;
|
params: Promise<{ id: string }>;
|
||||||
|
|
@ -128,6 +129,15 @@ export default async function MiiPage({ params }: Props) {
|
||||||
<p className="font-medium">This Mii is flagged as controversial and only appears when the filter is enabled</p>
|
<p className="font-medium">This Mii is flagged as controversial and only appears when the filter is enabled</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{mii.in_queue && (
|
||||||
|
<div className="bg-zinc-50 border-2 border-zinc-400 rounded-2xl shadow-lg p-4 flex items-center gap-3 text-zinc-700">
|
||||||
|
<Icon icon="material-symbols:timer" className="text-2xl shrink-0" />
|
||||||
|
<p className="font-medium">
|
||||||
|
This Mii is waiting to be manually reviewed {!settings.queueEnabled && "due to inappropriate images "}
|
||||||
|
and is hidden from the main page.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="relative grid grid-cols-3 gap-4 max-md:grid-cols-1">
|
<div className="relative grid grid-cols-3 gap-4 max-md:grid-cols-1">
|
||||||
<div className="bg-amber-50 rounded-3xl border-2 border-amber-500 shadow-lg p-4 h-min flex flex-col items-center max-w-md w-full max-md:place-self-center max-md:row-start-2">
|
<div className="bg-amber-50 rounded-3xl border-2 border-amber-500 shadow-lg p-4 h-min flex flex-col items-center max-w-md w-full max-md:place-self-center max-md:row-start-2">
|
||||||
{/* Mii Image */}
|
{/* Mii Image */}
|
||||||
|
|
@ -335,7 +345,7 @@ export default async function MiiPage({ params }: Props) {
|
||||||
|
|
||||||
{/* Author and Created date */}
|
{/* Author and Created date */}
|
||||||
<div className="mt-2">
|
<div className="mt-2">
|
||||||
<Link href={`/profile/${mii.userId}`} className="text-lg">
|
<Link href={`/profile/${mii.userId}`} className="text-lg wrap-break-word">
|
||||||
By <span className="font-bold">{mii.user.name}</span>
|
By <span className="font-bold">{mii.user.name}</span>
|
||||||
</Link>
|
</Link>
|
||||||
<h4 className="text-sm">
|
<h4 className="text-sm">
|
||||||
|
|
|
||||||
|
|
@ -60,13 +60,6 @@ export async function validateImage(file: File): Promise<{ valid: boolean; error
|
||||||
formData.append("image", blob);
|
formData.append("image", blob);
|
||||||
|
|
||||||
const moderationResponse = await fetch("https://api.trafficlunar.net/moderate/image", { method: "POST", body: formData });
|
const moderationResponse = await fetch("https://api.trafficlunar.net/moderate/image", { method: "POST", body: formData });
|
||||||
|
|
||||||
if (!moderationResponse.ok) {
|
|
||||||
console.error("Moderation API error");
|
|
||||||
Sentry.captureException("Moderation API error", { extra: { stage: "moderation-api-response", status: moderationResponse.status } });
|
|
||||||
return { valid: false, error: "Content moderation check failed", status: 500 };
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await moderationResponse.json();
|
const result = await moderationResponse.json();
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
return { valid: false, error: result.error };
|
return { valid: false, error: result.error };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue