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',
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';

View File

@@ -20,6 +20,7 @@ type DayEnum = z.infer<typeof DayEnumSchema>;
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}$/)) {