Integrate message into notification

This commit is contained in:
Xevion
2023-02-25 03:23:21 -06:00
parent d43b9eeefc
commit a4de4cffdf
2 changed files with 6 additions and 3 deletions

View File

@@ -45,6 +45,7 @@ export default async function handler(
{ {
time: '03:13', time: '03:13',
maxLate: '00:10', maxLate: '00:10',
message: 'The bus is leaving soon.',
days: [ days: [
'monday', 'monday',
'tuesday', 'tuesday',
@@ -57,10 +58,11 @@ export default async function handler(
name: 'B' name: 'B'
}, },
{ {
name: 'A',
message: 'The bus is leaving soon.',
time: '23:26', time: '23:26',
maxLate: '00:10', maxLate: '00:10',
days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'], days: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']
name: 'A'
} }
] ]
}); });
@@ -77,7 +79,7 @@ export default async function handler(
if (await checkIdentifier(matching.name, now)) return 'already-notified'; if (await checkIdentifier(matching.name, now)) return 'already-notified';
// Send notification, mark // 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); await markIdentifier(matching.name, true, 60 * 60 * 24 * 31, now);
return 'notified'; return 'notified';

View File

@@ -20,6 +20,7 @@ type DayEnum = z.infer<typeof DayEnumSchema>;
const TimeConfigSchema = z.object({ const TimeConfigSchema = z.object({
// A short name to be included in notifications // A short name to be included in notifications
name: z.string(), name: z.string(),
message: z.string(),
// The time this notification is intended for. e.g. "12:00", 24 hour time // The time this notification is intended for. e.g. "12:00", 24 hour time
time: z.string().transform((time, ctx) => { time: z.string().transform((time, ctx) => {
if (!time.match(/^[0-9]{2}:[0-9]{2}$/)) { if (!time.match(/^[0-9]{2}:[0-9]{2}$/)) {