Initial commit

This commit is contained in:
Jarek Krochmalski
2025-12-28 21:16:03 +01:00
commit 62e3c6439e
552 changed files with 104858 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import { json } from '@sveltejs/kit';
import { getNotificationSetting } from '$lib/server/db';
import { testNotification } from '$lib/server/notifications';
import type { RequestHandler } from './$types';
export const POST: RequestHandler = async ({ params }) => {
try {
const id = parseInt(params.id);
if (isNaN(id)) {
return json({ error: 'Invalid ID' }, { status: 400 });
}
const setting = await getNotificationSetting(id);
if (!setting) {
return json({ error: 'Notification setting not found' }, { status: 404 });
}
const success = await testNotification(setting);
return json({
success,
message: success ? 'Test notification sent successfully' : 'Failed to send test notification'
});
} catch (error: any) {
console.error('Error testing notification:', error);
return json({
success: false,
error: error.message || 'Failed to test notification'
}, { status: 500 });
}
};