add option to create a report via the admin panel
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				delpoy / build-and-deploy (push) Successful in 47s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	delpoy / build-and-deploy (push) Successful in 47s
				
			This commit is contained in:
		| @@ -1,11 +1,12 @@ | ||||
| import type { RequestHandler } from '@sveltejs/kit'; | ||||
| import { Report, User } from '$lib/server/database'; | ||||
| import * as crypto from 'crypto'; | ||||
| import { env } from '$env/dynamic/public'; | ||||
|  | ||||
| export const POST = (async ({ request, url }) => { | ||||
| 	const data: { reporter: string; reported: string; reason: string } = await request.json(); | ||||
|  | ||||
| 	if (data.reporter == undefined || data.reported == undefined || data.reason == undefined) | ||||
| 	if (data.reporter == null || data.reported == null || data.reason == null) | ||||
| 		return new Response(null, { status: 400 }); | ||||
|  | ||||
| 	const reporter = await User.findOne({ where: { uuid: data.reporter } }); | ||||
| @@ -25,7 +26,9 @@ export const POST = (async ({ request, url }) => { | ||||
| 	}); | ||||
|  | ||||
| 	return new Response( | ||||
| 		JSON.stringify({ url: `${url.toString().replace(/\/$/, '')}/${report.url_hash}` }), | ||||
| 		JSON.stringify({ | ||||
| 			url: `${url.protocol}//${url.host}${env.PUBLIC_BASE_PATH || ''}/report/${report.url_hash}` | ||||
| 		}), | ||||
| 		{ | ||||
| 			status: 201 | ||||
| 		} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user