feat: support array target in transparency routes
This commit is contained in:
parent
c5fe9408cc
commit
ca16c361aa
|
|
@ -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<boolean>`${id} = ANY(target)`)
|
||||
.executeTakeFirst()
|
||||
if (!json) return error(404, 'Report not found.')
|
||||
|
||||
|
|
|
|||
|
|
@ -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<boolean>`${json.id} = ANY(target)`)
|
||||
.execute()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<div class="grid">
|
||||
<% it.data.forEach(function(r){ %>
|
||||
<a class="title" href="/transparency/<%= r.target %>"><%= r.title %></a>
|
||||
<a class="title" href="/transparency/<%= r.target[0] %>"><%= r.title %></a>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@
|
|||
<div class="reports">
|
||||
<span class="reports-title">Somebody has complained about this video...</span> <br/>
|
||||
<% it.transparency.forEach(function(t){ %>
|
||||
<a href="/transparency/<%= t.target %>"><%= t.title %></a>
|
||||
<a href="/transparency/<%= it.id %>"><%= t.title %></a>
|
||||
<% }) %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
|
|
|||
|
|
@ -36,11 +36,12 @@ export type UpdateVideo = Updateable<VideosTable>
|
|||
|
||||
export interface ReportsTable {
|
||||
uuid: Generated<string>
|
||||
target: string
|
||||
target: string[]
|
||||
title: string
|
||||
details: string
|
||||
date: Date
|
||||
pdf_url?: string | null
|
||||
hidden?: boolean
|
||||
}
|
||||
|
||||
export type Report = Selectable<ReportsTable>
|
||||
|
|
|
|||
Loading…
Reference in New Issue