From 7b2e336eca1556e70243cc047bfeb27b9850a7ed Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 3 May 2024 14:45:01 +0800 Subject: [PATCH] log unknown channel --- packages/api/src/jobs/ai/create_digest.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/api/src/jobs/ai/create_digest.ts b/packages/api/src/jobs/ai/create_digest.ts index 81c6512f8..87990ea4d 100644 --- a/packages/api/src/jobs/ai/create_digest.ts +++ b/packages/api/src/jobs/ai/create_digest.ts @@ -595,8 +595,8 @@ const sendEmail = async (user: User, digest: Digest) => { const sendNotifications = async ( user: User, - channels: Channel[], - digest: Digest + digest: Digest, + channels: Channel[] = ['push'] // default to push notification ) => { const deduplicateChannels = [...new Set(channels)] @@ -608,6 +608,8 @@ const sendNotifications = async ( case 'email': return sendEmail(user, digest) default: + logger.error('Unknown channel', { channel }) + return } }) ) @@ -721,10 +723,8 @@ export const createDigest = async (jobData: CreateDigestData) => { jobState: TaskState.Failed, }) } finally { - // default to push notification - const channels = config?.channels ?? ['push'] // send notification - await sendNotifications(user, channels, digest) + await sendNotifications(user, digest, config?.channels) console.timeEnd('createDigestJob') }