feat: deliver leader summaries by webhook
This commit is contained in:
1 parent
515b545b32
commit
be17f6c361
21 files changed
+1260
-1269
No files matched your search
@@ -443,6 +443,8 @@ export async function buildServer({
|
||||
database_ssl: config.DATABASE_SSL,
|
||||
artifact_storage_backend: config.ARTIFACT_STORAGE_BACKEND,
|
||||
agentbus_enabled: config.agentBusEnabled,
|
||||
leader_summary_webhook_enabled: config.leaderSummaryWebhookEnabled,
|
||||
leader_summary_webhook_configuration_error: config.leaderSummaryWebhookConfigurationError,
|
||||
parser_loop_enabled: startParserLoop,
|
||||
data_retention_enabled: config.DATA_RETENTION_ENABLED,
|
||||
raw_payload_logging: config.AGENTBUS_LOG_PAYLOADS
|
||||
@@ -539,9 +541,9 @@ export async function buildServer({
|
||||
error: (metadata, message) => app.log.error(agentBusDiagnosticMetadata(metadata), message)
|
||||
});
|
||||
const leaderNotificationService = new LeaderNotificationService(config, {
|
||||
info: (metadata, message) => app.log.info(agentBusDiagnosticMetadata(metadata), message),
|
||||
warn: (metadata, message) => app.log.warn(agentBusDiagnosticMetadata(metadata), message),
|
||||
error: (metadata, message) => app.log.error(agentBusDiagnosticMetadata(metadata), message)
|
||||
info: (metadata, message) => app.log.info(metadata, message),
|
||||
warn: (metadata, message) => app.log.warn(metadata, message),
|
||||
error: (metadata, message) => app.log.error(metadata, message)
|
||||
});
|
||||
let agentBus: AgentBusManager | null = null;
|
||||
|
||||
@@ -844,7 +846,6 @@ export async function buildServer({
|
||||
tasks,
|
||||
organizationId: organization.id,
|
||||
scheduleParseQueue,
|
||||
leaderNotifications: leaderNotificationService,
|
||||
logger: {
|
||||
info: (metadata, message) => app.log.info(agentBusDiagnosticMetadata(metadata), message),
|
||||
warn: (metadata, message) => app.log.warn(agentBusDiagnosticMetadata(metadata), message),
|
||||
@@ -852,7 +853,26 @@ export async function buildServer({
|
||||
}
|
||||
});
|
||||
await agentBus.start();
|
||||
leaderNotificationService.startProjector(organization.id);
|
||||
}
|
||||
if (config.leaderSummaryWebhookEnabled) {
|
||||
try {
|
||||
const organization = await auth.getOrganization();
|
||||
if (organization) {
|
||||
leaderNotificationService.startProjector(organization.id);
|
||||
} else {
|
||||
app.log.warn({
|
||||
diagnostic_event: 'leader_summary.webhook_initialization_skipped',
|
||||
notification_event: 'webhook_initialization_skipped',
|
||||
error_code: 'leader_summary_webhook_organization_not_found'
|
||||
}, 'Leader summary webhook initialization skipped; normal task services remain available');
|
||||
}
|
||||
} catch (error) {
|
||||
app.log.warn({
|
||||
diagnostic_event: 'leader_summary.webhook_initialization_failed',
|
||||
notification_event: 'webhook_initialization_failed',
|
||||
...diagnosticError(error, 'leader_summary_webhook_initialization_failed')
|
||||
}, 'Leader summary webhook initialization failed; normal task services remain available');
|
||||
}
|
||||
}
|
||||
|
||||
async function getAiProbe(): Promise<unknown> {
|
||||
@@ -1206,11 +1226,11 @@ export async function buildServer({
|
||||
return { ok: true, ...result };
|
||||
});
|
||||
|
||||
app.get('/api/settings/leader-summary-subscriptions', async (request) => {
|
||||
app.get('/api/settings/leader-summary-webhook', async (request) => {
|
||||
const session = await requireAdminSession(request);
|
||||
return {
|
||||
ok: true,
|
||||
subscriptions: await leaderNotificationService.listSubscriptions(session.user.organizationId)
|
||||
status: await leaderNotificationService.getWebhookStatus(session.user.organizationId)
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user