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[]
|
events: FeedEvent[]
|
||||||
) {
|
) {
|
||||||
let frequencyToken = token.paragraph('Range: Every Event');
|
let frequencyText = 'Single Event';
|
||||||
if (channel.notifyFrequency === FeedChannelNotifyFrequency.day) {
|
if (channel.notifyFrequency === FeedChannelNotifyFrequency.day) {
|
||||||
frequencyToken = token.paragraph(
|
frequencyText = `Daily | ${dayjs().subtract(1, 'day').toISOString()} - ${dayjs().toISOString()}`;
|
||||||
`Range: Daily | ${dayjs().subtract(1, 'day').toISOString()} - ${dayjs().toISOString()}`
|
|
||||||
);
|
|
||||||
} else if (channel.notifyFrequency === FeedChannelNotifyFrequency.week) {
|
} else if (channel.notifyFrequency === FeedChannelNotifyFrequency.week) {
|
||||||
frequencyToken = token.paragraph(
|
frequencyText = `Weekly | ${dayjs().subtract(1, 'week').toISOString()} - ${dayjs().toISOString()}`;
|
||||||
`Range: Weekly | ${dayjs().subtract(1, 'week').toISOString()} - ${dayjs().toISOString()}`
|
|
||||||
);
|
|
||||||
} else if (channel.notifyFrequency === FeedChannelNotifyFrequency.month) {
|
} else if (channel.notifyFrequency === FeedChannelNotifyFrequency.month) {
|
||||||
frequencyToken = token.paragraph(
|
frequencyText = `Monthly | ${dayjs().subtract(1, 'month').toISOString()} - ${dayjs().toISOString()}`;
|
||||||
`Range: Monthly | ${dayjs().subtract(1, 'month').toISOString()} - ${dayjs().toISOString()}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const eventTokens: ContentToken[] = [
|
const eventTokens: ContentToken[] = [
|
||||||
token.title('Feed Report from Channel: ' + channel.name, 2),
|
|
||||||
frequencyToken,
|
|
||||||
token.list(
|
token.list(
|
||||||
events.map((event) =>
|
events.map((event) =>
|
||||||
token.text(
|
token.text(
|
||||||
@ -97,7 +89,11 @@ export async function sendFeedEventsNotify(
|
|||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
channel.notifications.map((notification) =>
|
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(
|
logger.error(
|
||||||
'[Notification] sendFeedEventsNotify',
|
'[Notification] sendFeedEventsNotify',
|
||||||
channel.id,
|
channel.id,
|
||||||
|
Loading…
Reference in New Issue
Block a user