add report selection via url hash
All checks were successful
delpoy / build-and-deploy (push) Successful in 48s

This commit is contained in:
2023-10-05 13:07:30 +02:00
parent 444631f649
commit 1f8cf66e90
3 changed files with 71 additions and 9 deletions

View File

@@ -22,9 +22,11 @@ export const POST = (async ({ request, cookies }) => {
status: 'none' | 'review' | 'reviewed' | null;
reporter: string | null;
reported: string | null;
hash: string | null;
} = await request.json();
const reportFindOptions: Attributes<Report> = {};
let reportFindOptions: Attributes<Report> = {};
if (data.draft != null) reportFindOptions.draft = data.draft;
reportFindOptions.status = data.status == null ? ['none', 'review'] : data.status;
if (data.reporter != null) {
@@ -41,6 +43,13 @@ export const POST = (async ({ request, cookies }) => {
});
reportFindOptions.reported_id = reported_ids.map((u) => u.id);
}
if (data.hash != null) {
reportFindOptions = { url_hash: data.hash };
data.from = 0;
data.limit = 1;
}
let reports = await Report.findAll({
where: reportFindOptions,
include: [