Added entity reporting.

This commit is contained in:
2026-11-13 00:23:13 +01:00
parent 6143c41668
commit 1d219850d7
18 changed files with 840 additions and 5 deletions
+4 -1
View File
@@ -3,16 +3,18 @@ import { renderPage } from 'vike/server';
import { socials } from '../../common/actors.mjs';
import pkg from '../../package.json' with { type: 'json' };
import { fetchAdminIndicators } from '../admin-indicators.js';
import { fetchUnseenNotificationsCount } from '../alerts.js';
import { fetchUserStashes } from '../stashes.js';
import { fetchUserTemplates } from '../users.js';
export default async function mainHandler(req, res, next) {
const [stashes, templates, unseenNotifications] = req.user
const [stashes, templates, unseenNotifications, adminIndicators] = req.user
? await Promise.all([
fetchUserStashes(req.user.id, req.user),
fetchUserTemplates(req.user),
fetchUnseenNotificationsCount(req.user),
fetchAdminIndicators(req.user),
])
: [];
@@ -38,6 +40,7 @@ export default async function mainHandler(req, res, next) {
primaryStash: stashes.find((stash) => stash.isPrimary),
templates,
unseenNotifications,
adminIndicators,
}
: null,
env: {
+20
View File
@@ -0,0 +1,20 @@
import { Router } from 'express';
import { createReport, updateReport } from '../reports.js';
async function createReportApi(req, res) {
const reportId = await createReport(Number(req.params.entityId), req.body, req.user);
res.send({ id: reportId });
}
async function updateReportApi(req, res) {
const report = await updateReport(Number(req.params.reportId), req.body, req.user);
res.send(report);
}
export const router = Router();
router.post('/api/entities/:entityId/reports', createReportApi);
router.patch('/api/reports/:reportId', updateReportApi);
+4 -2
View File
@@ -27,11 +27,12 @@ import { graphqlApi } from './graphql.js';
import mainHandler from './main.js';
import { fetchMoviesApi } from './movies.js';
import { router as reportsRouter } from './reports.js';
import initRestrictionHandler from './restrictions.js';
import { scenesRouter } from './scenes.js';
import serializeApiResponses from './serialize.js';
import serializeApiResponses from './serialize.js';
import { router as stashesRouter } from './stashes.js';
import { syncRouter } from './sync.js';
import { initCachesApi } from './system.js';
@@ -128,6 +129,7 @@ export default async function initServer() {
router.use(userRouter);
router.use(stashesRouter);
router.use(reportsRouter);
router.use(alertsRouter);
router.use(authRouter);
router.use(scenesRouter);