Compare commits

..

6 Commits

Author SHA1 Message Date
62319a84d1 Apply hack to display images 2025-07-27 00:52:44 -04:00
195af5e124 Bump node version 2025-07-27 00:37:27 -04:00
f9d9bdbac6 Enforce submission type in upload endpoint 2025-07-27 00:25:59 -04:00
451d1c93d4 Allow images in upload signer 2025-07-27 00:24:59 -04:00
157c9b188b Allow images on frontend 2025-07-27 00:09:30 -04:00
8d357ec249 Add report submission type radio 2025-07-27 00:03:10 -04:00
5 changed files with 63 additions and 8 deletions

View File

@@ -1 +1 @@
v22.13.1
v22.17.1

View File

@@ -9,9 +9,12 @@ import {
HStack,
Input,
Link,
Radio,
RadioGroup,
Text,
Textarea,
useToast,
VStack,
} from "@chakra-ui/react";
import { useEffect, useState } from "react";
import { useLoaderData } from "@remix-run/react";
@@ -31,28 +34,34 @@ export async function loader({
export function meta() {
return [
{
title: "Report an Exploiter - Car Crushers",
title: "Send a Report - Car Crushers",
},
{
name: "description",
content: "Use this page to report a cheater",
content: "Use this page to submit a report",
},
];
}
export default function () {
const [fileProgress, setFileProgress] = useState(0);
const [submissionType, setSubmissionType] = useState("exploiter");
const [showSuccess, setShowSuccess] = useState(false);
const toast = useToast();
const [uploading, setUploading] = useState(false);
const [loading, setLoading] = useState(false);
const fileTypes: { [k: string]: string } = {
avif: "image/avif",
gif: "image/gif",
jpg: "image/jpeg",
jpeg: "image/jpeg",
m4v: "video/x-m4v",
mkv: "video/x-matroska",
mov: "video/mp4",
mp4: "video/mp4",
png: "image/png",
webm: "video/webm",
webp: "image/webp",
wmv: "video/x-ms-wmv",
};
@@ -132,6 +141,7 @@ export default function () {
body: JSON.stringify({
description: description || undefined,
files: filelist,
submissionType,
turnstileResponse: logged_in ? undefined : turnstileToken,
usernames,
}),
@@ -277,6 +287,20 @@ export default function () {
<Input id="usernames" placeholder="builderman" />
</FormControl>
<br />
<FormControl isRequired>
<FormLabel htmlFor="submissionType">Type of Report</FormLabel>
<RadioGroup
id="submissionType"
onChange={setSubmissionType}
value={submissionType}
>
<VStack spacing={2}>
<Radio value="exploit">Exploiter</Radio>
<Radio value="abuse">Server Configurator Abuse</Radio>
</VStack>
</RadioGroup>
</FormControl>
<br />
<FormControl isRequired>
<FormLabel>Your Evidence (Max size per file: 512MB)</FormLabel>
<Button

View File

@@ -69,7 +69,11 @@ export default function (props: ReportCardProps & { port?: MessagePort }) {
<div style={{ position: "relative" }}>
<video controls={true} width="100%">
<source src={`/api/uploads/${props.attachments[attachmentIdx]}`} />
<source src="/files/processing.webm" />
<img
alt="User submission evidence"
src={`/api/uploads/${props.attachments[attachmentIdx]}`}
width="100%"
/>
</video>
<HStack
pos="absolute"

View File

@@ -2,8 +2,14 @@ import { jsonError, jsonResponse } from "../../common.js";
import upload from "../../upload.js";
export async function onRequestPost(context: RequestContext) {
const { description, files, senderTokenId, turnstileResponse, usernames } =
context.data.body;
const {
description,
files,
senderTokenId,
submissionType,
turnstileResponse,
usernames,
} = context.data.body;
if (!context.data.current_user) {
if (typeof turnstileResponse !== "string")
@@ -32,6 +38,9 @@ export async function onRequestPost(context: RequestContext) {
if (!Array.isArray(usernames))
return jsonError("Usernames must be type of array", 400);
if (!["abuse", "exploit"].includes(submissionType))
return jsonError("Invalid submission type", 400);
if (
!["string", "undefined"].includes(typeof description) ||
description?.length > 512
@@ -131,7 +140,19 @@ export async function onRequestPost(context: RequestContext) {
if (
fileParts.length < 2 ||
!["mkv", "mp4", "wmv", "m4v", "gif", "webm"].includes(fileExten)
![
"avif",
"gif",
"jpeg",
"jpg",
"m4v",
"mkv",
"mp4",
"png",
"webm",
"webp",
"wmv",
].includes(fileExten)
)
return jsonError(
`File ${file.name} cannot be uploaded as it is unsupported`,
@@ -196,7 +217,7 @@ export async function onRequestPost(context: RequestContext) {
}
await context.env.D1.prepare(
"INSERT INTO reports (attachments, created_at, id, open, target_ids, target_usernames, user) VALUES (?, ?, ?, 1, ?, ?, ?);",
"INSERT INTO reports (attachments, created_at, id, open, target_ids, target_usernames, type, user) VALUES (?, ?, ?, 1, ?, ?, ?, ?);",
)
.bind(
JSON.stringify(attachments),
@@ -204,6 +225,7 @@ export async function onRequestPost(context: RequestContext) {
reportId,
JSON.stringify(metaIDs),
JSON.stringify(metaNames),
submissionType,
currentUser ? JSON.stringify(currentUser) : null,
)
.run();

View File

@@ -1,12 +1,17 @@
import { AwsClient } from "aws4fetch";
const contentTypes: { [k: string]: string } = {
avif: "image/avif",
gif: "image/gif",
jpeg: "image/jpeg",
jpg: "image/jpeg",
m4v: "video/x-m4v",
mkv: "video/x-matroska",
mov: "video/mp4",
mp4: "video/mp4",
png: "image/png",
webm: "video/webm",
webp: "image/webp",
wmv: "video/x-ms-wmv",
};