- 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
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { MsGraphClient, MsGraphClientConfig } from './msgraph-client';
|
|
|
|
let msGraphClientInstance: MsGraphClient | null = null;
|
|
|
|
/**
|
|
* Check if Microsoft Graph credentials are configured
|
|
*/
|
|
export function isMsgraphConfigured(): boolean {
|
|
return !!(
|
|
process.env.MSGRAPH_CLIENT_ID &&
|
|
process.env.MSGRAPH_CLIENT_SECRET &&
|
|
process.env.MSGRAPH_TENANT_ID
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get or create Microsoft Graph client singleton
|
|
*/
|
|
export function getMsgraphClient(): MsGraphClient {
|
|
if (!msGraphClientInstance) {
|
|
const config: MsGraphClientConfig = {
|
|
tenantId: process.env.MSGRAPH_TENANT_ID || '',
|
|
clientId: process.env.MSGRAPH_CLIENT_ID || '',
|
|
clientSecret: process.env.MSGRAPH_CLIENT_SECRET || '',
|
|
};
|
|
|
|
if (!config.tenantId || !config.clientId || !config.clientSecret) {
|
|
throw new Error(
|
|
'Microsoft Graph credentials missing. Set MSGRAPH_CLIENT_ID, MSGRAPH_CLIENT_SECRET, and MSGRAPH_TENANT_ID.'
|
|
);
|
|
}
|
|
|
|
msGraphClientInstance = new MsGraphClient(config);
|
|
console.log('[MSGRAPH] Client initialized');
|
|
}
|
|
|
|
return msGraphClientInstance;
|
|
}
|
|
|
|
export function resetMsgraphClient(): void {
|
|
msGraphClientInstance = null;
|
|
}
|