Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5eb3146
#4090 moved slack notif field from event type to event
porpol Apr 2, 2026
8c31acb
#4090 moved slack notifs field from event type to event in shared types
porpol Apr 2, 2026
dcdb053
#4090 moved slack notifs field from event type to event in routes
porpol Apr 5, 2026
b4f6362
#4090 moved slack notifs field from event type to event controllers
porpol Apr 5, 2026
7d6ec78
#4090 moved sendslacknotifs from event type to event services, and ch…
porpol Apr 5, 2026
6f16f84
#4090 moved sendslacknotifs from event type to event transformers
porpol Apr 5, 2026
21ae075
#4090 send slack notifs service filters using event instead of eventtype
porpol Apr 6, 2026
ce55512
#4090 fixed schema formatting
porpol Apr 6, 2026
776a4be
#4090 made migration for moving sendslacknotifs field
porpol Apr 6, 2026
24126c2
#4090 modified tests to match new sendslacknotifs field
porpol Apr 6, 2026
83d2250
#4090 moved sendSlackNotifs to correct position in editEvent and crea…
porpol Apr 14, 2026
ae3726c
#4090 removed unnecessary sendSlackNotifs parameter in validation call
porpol Apr 14, 2026
b955b7c
#4090 removed foundEventType from scheduleEvent as it is not necessar…
porpol Apr 14, 2026
517c5a7
#4090 modified seeded events/eventtypes so that sendslacknotifs is in…
porpol Apr 14, 2026
a48d266
#4090 fixed tests involving create/edit events and event types
porpol Apr 14, 2026
38cac06
#4090 fixed prettier formatting
porpol Apr 14, 2026
b156d65
#4090 added sendslacknotifs to event with members shared type
porpol Apr 14, 2026
8c645f7
#4090 fixed createEventType call (it had a schedule parameter for som…
porpol Apr 14, 2026
b708ab6
#4090 sendslacknotifs has default value of false
porpol Apr 16, 2026
58d4877
#4090 schema formatting fixed
porpol Apr 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/backend/src/controllers/calendar.controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default class CalendarController {
documents,
description,
onlyHeadsOrAbove,
requiresConfirmation,
sendSlackNotifications
requiresConfirmation
} = req.body;

const eventType = await CalendarService.createEventType(
Expand All @@ -43,8 +42,7 @@ export default class CalendarController {
documents,
description,
onlyHeadsOrAbove,
requiresConfirmation,
sendSlackNotifications
requiresConfirmation
);
res.status(200).json(eventType);
} catch (error: unknown) {
Expand Down Expand Up @@ -205,8 +203,7 @@ export default class CalendarController {
documents,
description,
onlyHeadsOrAbove,
requiresConfirmation,
sendSlackNotifications
requiresConfirmation
} = req.body;

const eventType = await CalendarService.editEventType(
Expand All @@ -228,8 +225,7 @@ export default class CalendarController {
documents,
description,
onlyHeadsOrAbove,
requiresConfirmation,
sendSlackNotifications
requiresConfirmation
);
res.status(200).json(eventType);
} catch (error: unknown) {
Expand Down Expand Up @@ -278,7 +274,8 @@ export default class CalendarController {
questionDocumentLink,
location,
zoomLink,
description
description,
sendSlackNotifications
} = req.body;

const parsedScheduleSlots = scheduleSlots.map((slot: any) => ({
Expand All @@ -302,6 +299,7 @@ export default class CalendarController {
workPackageIds,
parsedScheduleSlots,
parsedInitialDateScheduled,
sendSlackNotifications,
teamTypeId,
questionDocumentLink,
location,
Expand Down Expand Up @@ -332,7 +330,8 @@ export default class CalendarController {
questionDocumentLink,
location,
zoomLink,
description
description,
sendSlackNotifications
} = req.body;

const event = await CalendarService.editEvent(
Expand All @@ -348,6 +347,7 @@ export default class CalendarController {
machineryIds,
workPackageIds,
documents,
sendSlackNotifications,
teamTypeId,
questionDocumentLink,
location,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Event" ADD COLUMN "sendSlackNotifications" BOOLEAN NOT NULL DEFAULT false;

-- AlterTable
ALTER TABLE "Event_Type" DROP COLUMN "sendSlackNotifications";
2 changes: 1 addition & 1 deletion src/backend/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,7 @@ model Event {
description String?
notificationSlackThreads Message_Info[]
calendarEventIds String[]
sendSlackNotifications Boolean @default(false)
}

model Calendar {
Expand Down Expand Up @@ -1221,7 +1222,6 @@ model Event_Type {
description Boolean
onlyHeadsOrAboveForEventCreation Boolean
requiresConfirmation Boolean
sendSlackNotifications Boolean
events Event[]
organizationId String
organization Organization @relation(fields: [organizationId], references: [organizationId])
Expand Down
13 changes: 9 additions & 4 deletions src/backend/src/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3576,7 +3576,6 @@ const performSeed: () => Promise<void> = async () => {
false,
true,
false,
false,
false
);

Expand All @@ -3599,7 +3598,6 @@ const performSeed: () => Promise<void> = async () => {
true,
true,
false,
true,
true
);

Expand All @@ -3622,7 +3620,6 @@ const performSeed: () => Promise<void> = async () => {
true,
false,
false,
false,
false
);

Expand All @@ -3645,7 +3642,6 @@ const performSeed: () => Promise<void> = async () => {
false,
false,
false,
false,
false
);

Expand All @@ -3668,6 +3664,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
true,
mechanical.teamTypeId,
undefined,
'Conference Room A',
Expand Down Expand Up @@ -3709,6 +3706,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
false,
mechanical.teamTypeId,
undefined,
'Conference Room A',
Expand All @@ -3735,6 +3733,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
false,
mechanical.teamTypeId,
undefined,
'Conference Room A',
Expand All @@ -3761,6 +3760,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
true,
mechanical.teamTypeId,
undefined,
'Conference Room A',
Expand All @@ -3787,6 +3787,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
true,
mechanical.teamTypeId,
undefined,
'Conference Room A',
Expand All @@ -3813,6 +3814,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
false,
mechanical.teamTypeId,
undefined,
'Conference Room A',
Expand All @@ -3833,6 +3835,7 @@ const performSeed: () => Promise<void> = async () => {
[workPackage1.id],
[],
weeksFromNow(1),
true,
software.teamTypeId,
'https://docs.google.com/document/d/2_example',
'Conference Room B',
Expand All @@ -3859,6 +3862,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
true,
electrical.teamTypeId,
'https://docs.google.com/document/d/3_example',
undefined,
Expand All @@ -3885,6 +3889,7 @@ const performSeed: () => Promise<void> = async () => {
}
],
undefined,
false,
mechanical.teamTypeId,
undefined,
undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/backend/src/routes/calendar.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ calendarRouter.post(
body('description').isBoolean(),
body('onlyHeadsOrAbove').isBoolean(),
body('requiresConfirmation').isBoolean(),
body('sendSlackNotifications').isBoolean(),
validateInputs,
CalendarController.createEventType
);
Expand All @@ -88,7 +87,6 @@ calendarRouter.post(
body('description').isBoolean(),
body('onlyHeadsOrAbove').isBoolean(),
body('requiresConfirmation').isBoolean(),
body('sendSlackNotifications').isBoolean(),
validateInputs,
CalendarController.editEventType
);
Expand Down Expand Up @@ -119,6 +117,7 @@ calendarRouter.post(
isDate(body('scheduleSlots.*.startTime')),
isDate(body('scheduleSlots.*.endTime')),
body('scheduleSlots.*.allDay').isBoolean(),
body('sendSlackNotifications').isBoolean(),
validateInputs,
CalendarController.createEvent
);
Expand Down Expand Up @@ -147,6 +146,7 @@ calendarRouter.post(
nonEmptyString(body('documents.*.googleFileId')),
body('questionDocumentLink').optional().isString(),
body('description').optional().isString(),
body('sendSlackNotifications').isBoolean(),
validateInputs,
CalendarController.editEvent
);
Expand Down
39 changes: 17 additions & 22 deletions src/backend/src/services/calendar.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export default class CalendarService {
* @param description Determines if a description is associated with this event type.
* @param onlyHeadsOrAbove Determines if events under this event type can only be created by heads or above.
* @param requiredConfirmation Determines if events under this event type need to be confirmed.
* @param sendSlackNotifications Determines if users will be notified via slack
*
* @returns The created event type.
*
Expand All @@ -116,8 +115,7 @@ export default class CalendarService {
documents: boolean,
description: boolean,
onlyHeadsOrAbove: boolean,
requiresConfirmation: boolean,
sendSlackNotifications: boolean
requiresConfirmation: boolean
): Promise<EventType> {
if (!(await userHasPermission(submitter.userId, organization.organizationId, isAdmin))) {
throw new AccessDeniedAdminOnlyException('create event type');
Expand Down Expand Up @@ -176,7 +174,6 @@ export default class CalendarService {
description,
onlyHeadsOrAboveForEventCreation: onlyHeadsOrAbove,
requiresConfirmation,
sendSlackNotifications,
organizationId: organization.organizationId
},
...getEventTypeQueryArgs(organization.organizationId)
Expand Down Expand Up @@ -246,6 +243,7 @@ export default class CalendarService {
* @param location Location of the event.
* @param zoomLink Zoom Link if the event is online.
* @param description Describes the event.
* @param sendSlackNotifications Determines if this event should receive slack notifications.
*
* @returns The created event.
*
Expand All @@ -265,6 +263,7 @@ export default class CalendarService {
workPackageIds: string[],
scheduleSlots: ScheduleSlotCreateArgs[],
initialDateScheduled: Date | undefined,
sendSlackNotifications: boolean,
teamTypeId?: string,
questionDocumentLink?: string,
location?: string,
Expand Down Expand Up @@ -460,7 +459,8 @@ export default class CalendarService {
location,
zoomLink,
questionDocumentLink,
description
description,
sendSlackNotifications
},
...getEventQueryArgs(organization.organizationId)
});
Expand Down Expand Up @@ -493,7 +493,7 @@ export default class CalendarService {
}
}

if (foundEventType.sendSlackNotifications) {
if (sendSlackNotifications) {
const members = await prisma.user.findMany({
where: { userId: { in: optionalMemberIds.concat(requiredMemberIds) } }
});
Expand Down Expand Up @@ -567,6 +567,7 @@ export default class CalendarService {
* @param location Location of the event.
* @param zoomLink Zoom Link if the event is online.
* @param description Describes the event.
* @param sendSlackNotifications Determines if this event should receive slack notifications.
*
* @returns The edited event.
*
Expand All @@ -586,6 +587,7 @@ export default class CalendarService {
machineryIds: string[],
workPackageIds: string[],
documents: EventDocumentCreateArgs[],
sendSlackNotifications: boolean,
teamTypeId?: string,
questionDocumentLink?: string,
location?: string,
Expand Down Expand Up @@ -773,7 +775,8 @@ export default class CalendarService {
location,
zoomLink,
questionDocumentLink,
description
description,
sendSlackNotifications
},
...getEventQueryArgs(organization.organizationId)
});
Expand All @@ -783,11 +786,11 @@ export default class CalendarService {

const edittedEvent = eventTransformer(updatedEvent);

if (status === Event_Status.SCHEDULED && foundEventType.sendSlackNotifications) {
if (status === Event_Status.SCHEDULED && sendSlackNotifications) {
await sendEventScheduledSlackNotif(updatedEvent.notificationSlackThreads, edittedEvent);
}

if (status === Event_Status.CONFIRMED && foundEventType.sendSlackNotifications) {
if (status === Event_Status.CONFIRMED && sendSlackNotifications) {
await sendEventConfirmationToThread(updatedEvent.notificationSlackThreads, updatedEvent.userCreated);
}

Expand Down Expand Up @@ -1350,7 +1353,7 @@ export default class CalendarService {
if (!foundEventType) throw new NotFoundException('Event Type', eventTypeId);
if (foundEventType.dateDeleted) throw new DeletedException('Event Type', eventTypeId);

if (foundEventType.sendSlackNotifications) {
if (updatedEvent.sendSlackNotifications) {
await sendEventUserConfirmationToThread(updatedEvent.notificationSlackThreads, submitter);
}

Expand All @@ -1366,7 +1369,7 @@ export default class CalendarService {
status: Event_Status.CONFIRMED
}
});
if (foundEventType.sendSlackNotifications) {
if (updatedEvent.sendSlackNotifications) {
await sendEventConfirmationToThread(updatedEvent.notificationSlackThreads, updatedEvent.userCreated);
}
}
Expand Down Expand Up @@ -1471,12 +1474,7 @@ export default class CalendarService {
});
}

const { eventTypeId } = updatedEvent;
const foundEventType = await prisma.event_Type.findUnique({
where: { eventTypeId }
});

if (foundEventType?.sendSlackNotifications) {
if (updatedEvent.sendSlackNotifications) {
await sendEventScheduledSlackNotif(updatedEvent.notificationSlackThreads, eventTransformer(updatedEvent));
}

Expand Down Expand Up @@ -2209,7 +2207,6 @@ export default class CalendarService {
* @param description Determines if a description is associated with this event type.
* @param onlyHeadsOrAbove Determines if events associated with this event type can only be made by heads or above.
* @param requiredConfirmation Determines if events associated with this event type need to be confirmed.
* @param sendSlackNotifications Determines if events associated with this event type should receive slack notifications.
*
* @returns The created event type.
*
Expand All @@ -2236,8 +2233,7 @@ export default class CalendarService {
documents: boolean,
description: boolean,
onlyHeadsOrAbove: boolean,
requiresConfirmation: boolean,
sendSlackNotifications: boolean
requiresConfirmation: boolean
): Promise<EventType> {
if (!(await userHasPermission(submitter.userId, organization.organizationId, isAdmin))) {
throw new AccessDeniedAdminOnlyException('edit event type');
Expand Down Expand Up @@ -2295,8 +2291,7 @@ export default class CalendarService {
documents,
description,
onlyHeadsOrAboveForEventCreation: onlyHeadsOrAbove,
requiresConfirmation,
sendSlackNotifications
requiresConfirmation
},
...getEventTypeQueryArgs(organization.organizationId)
});
Expand Down
Loading
Loading