From 88f47db118968aa323b6ee0eac6b14e4fe9aa608 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Mon, 2 Sep 2024 21:21:30 +0800 Subject: [PATCH] perf: improve feed event report style --- src/server/model/feed/event.ts | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/server/model/feed/event.ts b/src/server/model/feed/event.ts index 2a65379..43433a4 100644 --- a/src/server/model/feed/event.ts +++ b/src/server/model/feed/event.ts @@ -68,24 +68,16 @@ export async function sendFeedEventsNotify( }, events: FeedEvent[] ) { - let frequencyToken = token.paragraph('Range: Every Event'); + let frequencyText = 'Single Event'; if (channel.notifyFrequency === FeedChannelNotifyFrequency.day) { - frequencyToken = token.paragraph( - `Range: Daily | ${dayjs().subtract(1, 'day').toISOString()} - ${dayjs().toISOString()}` - ); + frequencyText = `Daily | ${dayjs().subtract(1, 'day').toISOString()} - ${dayjs().toISOString()}`; } else if (channel.notifyFrequency === FeedChannelNotifyFrequency.week) { - frequencyToken = token.paragraph( - `Range: Weekly | ${dayjs().subtract(1, 'week').toISOString()} - ${dayjs().toISOString()}` - ); + frequencyText = `Weekly | ${dayjs().subtract(1, 'week').toISOString()} - ${dayjs().toISOString()}`; } else if (channel.notifyFrequency === FeedChannelNotifyFrequency.month) { - frequencyToken = token.paragraph( - `Range: Monthly | ${dayjs().subtract(1, 'month').toISOString()} - ${dayjs().toISOString()}` - ); + frequencyText = `Monthly | ${dayjs().subtract(1, 'month').toISOString()} - ${dayjs().toISOString()}`; } const eventTokens: ContentToken[] = [ - token.title('Feed Report from Channel: ' + channel.name, 2), - frequencyToken, token.list( events.map((event) => token.text( @@ -97,7 +89,11 @@ export async function sendFeedEventsNotify( await Promise.all( channel.notifications.map((notification) => - sendNotification(notification, 'Feed Report', eventTokens).catch((err) => + sendNotification( + notification, + `Feed Report from Channel: ${channel.name} | ${frequencyText}`, + eventTokens + ).catch((err) => logger.error( '[Notification] sendFeedEventsNotify', channel.id,