mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-26 06:23:35 -04:00
23 lines
792 B
TypeScript
23 lines
792 B
TypeScript
import SQL from 'sql-template-strings';
|
|
|
|
import { getLocale, loadConfig } from '~/server/data.ts';
|
|
import { linkOtherVersions } from '~/server/sources.ts';
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
const locale = getLocale(event);
|
|
checkIsConfigEnabledOr404(await loadConfig(locale), 'sources');
|
|
|
|
const { isGranted } = await useAuthentication(event);
|
|
|
|
const id = getRouterParam(event, 'id');
|
|
const db = useDatabase();
|
|
return await linkOtherVersions(db, isGranted, locale, await db.all(SQL`
|
|
SELECT s.*, u.username AS submitter FROM sources s
|
|
LEFT JOIN users u ON s.submitter_id = u.id
|
|
WHERE s.locale = ${locale}
|
|
AND s.deleted = 0
|
|
AND s.approved >= ${isGranted('sources') ? 0 : 1}
|
|
AND s.id = ${id}
|
|
`));
|
|
});
|