From 82bb2ad267ae1f2922924fddb986b9f4e619eb1e Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Wed, 17 Jul 2024 00:38:21 +0800 Subject: [PATCH] fix: fix problem of send notification --- src/server/cache/index.ts | 4 +++- src/server/model/feed/event.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/server/cache/index.ts b/src/server/cache/index.ts index cf171bb..7bd6362 100644 --- a/src/server/cache/index.ts +++ b/src/server/cache/index.ts @@ -37,7 +37,9 @@ export function buildQueryWithCache( const realValue = await fetchFn(...args); - await cacheManager.set(key, JSON.stringify(cachedValue)); + if (realValue) { + await cacheManager.set(key, JSON.stringify(realValue)); + } return realValue; }; diff --git a/src/server/model/feed/event.ts b/src/server/model/feed/event.ts index f13841c..7e2bf76 100644 --- a/src/server/model/feed/event.ts +++ b/src/server/model/feed/event.ts @@ -10,6 +10,7 @@ import { serializeJSON } from '../../utils/json'; import { buildQueryWithCache } from '../../cache'; import { sendNotification } from '../notification'; import { token } from '../notification/token'; +import { logger } from '../../utils/logger'; const { get: getFeedEventNotify, del: delFeedEventNotifyCache } = buildQueryWithCache(async (channelId: string) => { @@ -69,7 +70,9 @@ export async function sendFeedEventsNotify( await Promise.all( notifications.map((notification) => - sendNotification(notification, 'Feed Report', eventTokens) + sendNotification(notification, 'Feed Report', eventTokens).catch((err) => + logger.error('[Notification] sendFeedEventsNotify', err) + ) ) ); }