- 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
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { isZoomConfigured } from '@/lib/services/zoom-factory';
|
|
import { getZoomSyncService } from '@/lib/services/zoom-sync-service';
|
|
import { postgresClient } from '@/lib/services/postgres-client';
|
|
|
|
export async function POST(_request: NextRequest) {
|
|
if (!isZoomConfigured()) {
|
|
return NextResponse.json(
|
|
{ error: 'Zoom credentials not configured' },
|
|
{ status: 503 }
|
|
);
|
|
}
|
|
|
|
const service = getZoomSyncService();
|
|
|
|
if (service.isSyncInProgress()) {
|
|
return NextResponse.json({ error: 'Zoom sync already in progress' }, { status: 409 });
|
|
}
|
|
|
|
// Fire-and-forget
|
|
service.sync().catch(err => {
|
|
console.error('[ZOOM-SYNC] Background sync failed:', err);
|
|
});
|
|
|
|
return NextResponse.json({ started: true });
|
|
}
|
|
|
|
export async function GET(_request: NextRequest) {
|
|
const service = getZoomSyncService();
|
|
|
|
let lastSynced: Date | null = null;
|
|
try {
|
|
const result = await postgresClient.query(
|
|
`SELECT MAX(synced_at) as last_synced FROM zoom_users`
|
|
);
|
|
lastSynced = result.rows[0]?.last_synced ?? null;
|
|
} catch {
|
|
// Table may not exist yet
|
|
}
|
|
|
|
return NextResponse.json({
|
|
isSyncing: service.isSyncInProgress(),
|
|
lastSynced,
|
|
configured: isZoomConfigured(),
|
|
});
|
|
}
|