mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
section 3: Phase 3: Auto-accept engine, default stamping and notificati
This commit is contained in:
1 parent
66e6c20f8e
commit
f85531f2d3
6 files changed
+391
-27
No files matched your search
@@ -139,9 +139,12 @@ export function buildEventNotificationPayload(
|
||||
};
|
||||
}
|
||||
|
||||
type EventSuppressor = (event: SSEEvent, sessionId: string | undefined) => Promise<boolean>;
|
||||
|
||||
export class NotificationService {
|
||||
private vapidConfig: VapidConfig | null = null;
|
||||
private settingsService: SettingsService;
|
||||
private eventSuppressors: EventSuppressor[] = [];
|
||||
|
||||
constructor(private db: Database) {
|
||||
this.settingsService = new SettingsService(db);
|
||||
@@ -178,6 +181,10 @@ export class NotificationService {
|
||||
return this.vapidConfig?.publicKey ?? null;
|
||||
}
|
||||
|
||||
addEventSuppressor(suppressor: EventSuppressor): void {
|
||||
this.eventSuppressors.push(suppressor);
|
||||
}
|
||||
|
||||
isConfigured(): boolean {
|
||||
return this.vapidConfig !== null;
|
||||
}
|
||||
@@ -321,6 +328,10 @@ export class NotificationService {
|
||||
if (sessionId && sseAggregator.isSessionBeingViewed(sessionId)) return;
|
||||
if (sessionId && sseAggregator.isSubagentSession(sessionId)) return;
|
||||
|
||||
for (const suppressor of this.eventSuppressors) {
|
||||
if (await suppressor(event, sessionId)) return;
|
||||
}
|
||||
|
||||
if (!this.isConfigured()) return;
|
||||
|
||||
const userIds = this.getAllUserIds();
|
||||
|
||||
Reference in new issue
Block a user