From a4de4cffdf94332efdde2d17327614dadd87ef2b Mon Sep 17 00:00:00 2001 From: Xevion Date: Sat, 25 Feb 2023 03:23:21 -0600 Subject: [PATCH] Integrate message into notification --- src/pages/api/cron.ts | 8 +++++--- src/timing.ts | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/api/cron.ts b/src/pages/api/cron.ts index f1b5ea7..e7f87fc 100644 --- a/src/pages/api/cron.ts +++ b/src/pages/api/cron.ts @@ -45,6 +45,7 @@ export default async function handler( { time: '03:13', maxLate: '00:10', + message: 'The bus is leaving soon.', days: [ 'monday', 'tuesday', @@ -57,10 +58,11 @@ export default async function handler( name: 'B' }, { + name: 'A', + message: 'The bus is leaving soon.', time: '23:26', maxLate: '00:10', - days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], - name: 'A' + days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'] } ] }); @@ -77,7 +79,7 @@ export default async function handler( if (await checkIdentifier(matching.name, now)) return 'already-notified'; // Send notification, mark - await sendNotification(`The bus is leaving soon. (${matching.name}))`); + await sendNotification(`${matching.message} (${matching.name})`); await markIdentifier(matching.name, true, 60 * 60 * 24 * 31, now); return 'notified'; diff --git a/src/timing.ts b/src/timing.ts index 6e84a98..3d584f6 100644 --- a/src/timing.ts +++ b/src/timing.ts @@ -20,6 +20,7 @@ type DayEnum = z.infer; const TimeConfigSchema = z.object({ // A short name to be included in notifications name: z.string(), + message: z.string(), // The time this notification is intended for. e.g. "12:00", 24 hour time time: z.string().transform((time, ctx) => { if (!time.match(/^[0-9]{2}:[0-9]{2}$/)) {