feat: another security sweep
Node.js CI / CI (push) Failing after 10s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m50s

This commit is contained in:
2026-02-04 22:02:24 -08:00
parent 5eae636f2f
commit 9caf74945a
10 changed files with 416 additions and 36 deletions
+27 -1
View File
@@ -4,6 +4,7 @@ import type {
SuggestionStatus,
SuggestionEntity,
CreateSuggestionDto,
AcceptWithEditsDto,
} from "@library/shared-types";
import {
GameStatus,
@@ -340,7 +341,7 @@ export const SuggestionService = {
return mapSuggestion(updatedSuggestion);
},
async acceptSuggestionWithEdits(id: string, editedData: any): Promise<Suggestion> {
async acceptSuggestionWithEdits(id: string, editedData: AcceptWithEditsDto): Promise<Suggestion> {
const suggestion = await prisma.suggestion.findUnique({
where: { id },
include: { user: true },
@@ -453,4 +454,29 @@ export const SuggestionService = {
return mapSuggestion(updatedSuggestion);
},
async deleteSuggestion(id: string, userId: string, isAdmin: boolean): Promise<Suggestion> {
const suggestion = await prisma.suggestion.findUnique({
where: { id },
include: { user: true },
});
if (!suggestion) {
throw new Error("Suggestion not found");
}
if (!isAdmin && suggestion.userId !== userId) {
throw new Error("You can only delete your own suggestions");
}
if (suggestion.status !== "UNREVIEWED") {
throw new Error("Cannot delete a suggestion that has already been reviewed");
}
await prisma.suggestion.delete({
where: { id },
});
return mapSuggestion(suggestion);
},
};