From ca16c361aaf4ff23f51cabda238ab67bbe1857a5 Mon Sep 17 00:00:00 2001 From: localhost Date: Mon, 31 Aug 2026 12:54:18 +0200 Subject: [PATCH] feat: support array target in transparency routes --- src/router/transparency.ts | 7 ++++++- src/router/video.ts | 3 ++- src/templates/transparency.eta | 2 +- src/templates/watch.eta | 2 +- src/types.ts | 3 ++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/router/transparency.ts b/src/router/transparency.ts index a71070e..89f1095 100644 --- a/src/router/transparency.ts +++ b/src/router/transparency.ts @@ -1,4 +1,5 @@ import { Elysia } from 'elysia'; +import { sql } from 'kysely' import { db } from '@/utils/database' import { m, eta, error } from '@/utils/html' @@ -15,6 +16,10 @@ app.get('/transparency', async ({ set }) => { const reports = await db.selectFrom('reports') .selectAll() + .where((eb) => eb.or([ + eb('hidden', 'is', null), + eb('hidden', '=', false) + ])) .orderBy('date desc') .execute() @@ -37,7 +42,7 @@ app.get('/transparency/:id', async ({ params: { id }, set, error }) => { const json = await db.selectFrom('reports') .selectAll() - .where('target', '=', id) + .where(sql`${id} = ANY(target)`) .executeTakeFirst() if (!json) return error(404, 'Report not found.') diff --git a/src/router/video.ts b/src/router/video.ts index 33e239e..1e098e6 100644 --- a/src/router/video.ts +++ b/src/router/video.ts @@ -1,4 +1,5 @@ import { Elysia } from 'elysia'; +import { sql } from 'kysely' import DOMPurify from 'isomorphic-dompurify' import { db } from '@/utils/database' @@ -91,7 +92,7 @@ app.get('/watch', async ({ query: { v }, set, redirect, error }) => { if (json.hasBeenReported) { transparency = await db.selectFrom('reports') .selectAll() - .where('target', '=', json.id) + .where(sql`${json.id} = ANY(target)`) .execute() } diff --git a/src/templates/transparency.eta b/src/templates/transparency.eta index 29fca03..9496ad2 100644 --- a/src/templates/transparency.eta +++ b/src/templates/transparency.eta @@ -2,7 +2,7 @@
<% it.data.forEach(function(r){ %> - <%= r.title %> + <%= r.title %> <% }) %>
diff --git a/src/templates/watch.eta b/src/templates/watch.eta index 46323e6..f9cd731 100644 --- a/src/templates/watch.eta +++ b/src/templates/watch.eta @@ -62,7 +62,7 @@
Somebody has complained about this video...
<% it.transparency.forEach(function(t){ %> - <%= t.title %> + <%= t.title %> <% }) %>
<% } %> diff --git a/src/types.ts b/src/types.ts index 0769703..1ec629c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -36,11 +36,12 @@ export type UpdateVideo = Updateable export interface ReportsTable { uuid: Generated - target: string + target: string[] title: string details: string date: Date pdf_url?: string | null + hidden?: boolean } export type Report = Selectable