Skip to content

Commit f3d3e25

Browse files
committed
feat(events.remote): add notifications for new shift assignments
1 parent df91418 commit f3d3e25

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

programmerbar-web/src/lib/remotes/events.remote.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export const createEvent = command(CreateEventSchema, async (event) => {
4848
const userIds = Array.from(new Set(mappedUserShifts.flatMap((shift) => shift.userId)));
4949
await sendShiftEmails(locals, userIds, createdEvent.name, createdShifts, shifts);
5050

51+
if (userIds.length > 0) {
52+
await locals.notificationService.sendNotifications(userIds, {
53+
title: 'Ny vakt tildelt',
54+
message: `Du har blitt tildelt en vakt for ${createdEvent.name}.`
55+
});
56+
}
57+
5158
return {
5259
success: true,
5360
eventId: createdEvent.id
@@ -81,7 +88,7 @@ async function sendShiftEmails(
8188
for (const userId of shiftData.users) {
8289
const user = users.find((u) => u.id === userId);
8390

84-
if (!user || !user.email) continue;
91+
if (!user || !user.email || !user.altEmail) continue;
8592

8693
emailsToSend.push({
8794
user: {

0 commit comments

Comments
 (0)