From c41fd0f6f6d5d634d4f874b42481bc5dbd583fe1 Mon Sep 17 00:00:00 2001 From: SmileQWQ Date: Mon, 20 Apr 2026 11:29:45 +0800 Subject: [PATCH] fix: clean notification scan for main --- apps/api/src/services/notification.service.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/apps/api/src/services/notification.service.ts b/apps/api/src/services/notification.service.ts index a010000..685468e 100644 --- a/apps/api/src/services/notification.service.ts +++ b/apps/api/src/services/notification.service.ts @@ -6,10 +6,6 @@ import { getAppSettings } from './settings.service' export type ReminderPhase = 'upcoming' | 'due_today' | 'overdue_day_1' | 'overdue_day_2' | 'overdue_day_3' -export type NotificationScanOptions = { - debugRunId?: string -} - export type NotificationScanResult = { processedCount: number notificationCount: number @@ -29,7 +25,7 @@ type ReminderRuleSettings = { overdueReminderDays: Array<1 | 2 | 3> } -type ReminderSubscriptionRow = { +type ReminderSubscriptionLike = { id: string name: string nextRenewalDate: Date @@ -133,7 +129,7 @@ export function resolveReminderPhase( } function buildDispatchEntry( - sub: ReminderSubscriptionRow, + sub: ReminderSubscriptionLike, currentDay: Date, resolved: NonNullable> ): ReminderDispatchEntry { @@ -213,17 +209,12 @@ function buildMergedPayload(entries: ReminderDispatchEntry[]) { } } -export async function scanRenewalNotifications( - today = new Date(), - options: NotificationScanOptions = {} -): Promise { +export async function scanRenewalNotifications(today = new Date()): Promise { const appSettings = await getAppSettings() const subscriptions = await prisma.subscription.findMany({ where: { status: { in: ['active', 'expired'] }, - webhookEnabled: true, - isDebugCopy: options.debugRunId ? true : false, - ...(options.debugRunId ? { debugRunId: options.debugRunId } : {}) + webhookEnabled: true }, include: { tags: { @@ -253,7 +244,7 @@ export async function scanRenewalNotifications( }) if (!resolved) continue - dispatchEntries.push(buildDispatchEntry(sub as ReminderSubscriptionRow, currentDay, resolved)) + dispatchEntries.push(buildDispatchEntry(sub, currentDay, resolved)) } if (!appSettings.mergeMultiSubscriptionNotifications || dispatchEntries.length <= 1) {