wulf-pulse/app/api/notifications/morning-summary/webhooks/[id]/route.ts
lorentz c518eefdb2 feat: Morning NOC Summary adaptive card for Teams
- Add MorningSummaryService with Zabbix aggregation and adaptive card builder
- Add webhook delivery system with Teams incoming webhooks
- Add admin UI at /admin/morning-summary for webhook/config management
- Add API routes: /send, /test, /webhooks, /webhooks/[id], /config, /history
- Register morning-summary cron job in SyncScheduler (Mon-Fri 6:30 AM)
- Add outages_only filter (Unavailable triggers only)
- Fix host resolution: use getTriggerEnabledHosts to exclude disabled hosts
- Fix resolved events: event.get value:1 scoped to window with r_eventid filter
- Remove emojis from fact rows and section headers in card
- Remove Open Zabbix button (duplicate of View Problems)
- Add migrations: morning_summary_config + morning_summaries tables
- Add outages_only column to morning_summary_config
2026-03-11 09:34:51 -04:00

33 lines
1.3 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import { getMorningSummaryService } from '@/lib/services/morning-summary-service';
export async function PUT(request: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id: rawId } = await params;
const id = parseInt(rawId, 10);
if (isNaN(id)) return NextResponse.json({ error: 'Invalid id' }, { status: 400 });
const body = await request.json();
const service = getMorningSummaryService();
const webhook = await service.updateWebhook(id, body);
return NextResponse.json({ webhook });
} catch (error) {
console.error('[PUT /api/notifications/morning-summary/webhooks/:id]', error);
return NextResponse.json({ error: String(error) }, { status: 500 });
}
}
export async function DELETE(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
try {
const { id: rawId } = await params;
const id = parseInt(rawId, 10);
if (isNaN(id)) return NextResponse.json({ error: 'Invalid id' }, { status: 400 });
const service = getMorningSummaryService();
await service.deleteWebhook(id);
return NextResponse.json({ deleted: true });
} catch (error) {
console.error('[DELETE /api/notifications/morning-summary/webhooks/:id]', error);
return NextResponse.json({ error: String(error) }, { status: 500 });
}
}