Add user avatar management and moderation
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { getDatabase } from '$lib/server/database';
|
||||
import { readUploadedAvatar } from '$lib/server/avatars';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
if (!/^[0-9a-f-]{36}$/i.test(params.id)) error(404, 'Avatar not found');
|
||||
const image = await readUploadedAvatar(await getDatabase(), params.id);
|
||||
if (!image) error(404, 'Avatar not found');
|
||||
return new Response(new Uint8Array(image), {
|
||||
headers: {
|
||||
'content-type': 'image/webp',
|
||||
'cache-control': 'public, max-age=31536000, immutable',
|
||||
'x-content-type-options': 'nosniff'
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user