perf: improve feed event report style
This commit is contained in:
parent
9966c1277c
commit
88f47db118
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user