Skip to content

Commit e2edc28

Browse files
committed
removed design review language from slack messages
1 parent a6bd95b commit e2edc28

5 files changed

Lines changed: 32 additions & 274 deletions

File tree

src/backend/src/controllers/design-reviews.controllers.ts

Lines changed: 0 additions & 137 deletions
This file was deleted.

src/backend/src/prisma-query-args/design-reviews.query-args.ts

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/backend/src/routes/design-reviews.routes.ts

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/backend/src/services/calendar.services.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
Calendar,
1414
FilterArgs,
1515
Machinery,
16-
ScheduleSlot
16+
ScheduleSlot,
17+
notGuest
1718
} from 'shared';
1819
import { getCalendarQueryArgs } from '../prisma-query-args/calendar.query-args.js';
1920
import { getEventTypeQueryArgs } from '../prisma-query-args/event-type.query-args.js';
@@ -285,6 +286,8 @@ export default class CalendarService {
285286
if (!hasPermission) {
286287
throw new AccessDeniedException('Only admins and heads can create events under this event type');
287288
}
289+
} else if (notGuest(submitter.role)) {
290+
throw new AccessDeniedGuestException('Guests cannot create events');
288291
}
289292

290293
// Validate event follows event type configuration
@@ -501,39 +504,33 @@ export default class CalendarService {
501504
where: { userId: { in: members.map((member) => member.userId) } }
502505
});
503506

504-
if (!memberUserSettings) {
505-
throw new NotFoundException('User Settings', 'Cannot find settings of members');
506-
}
507-
508507
const workPackageNames = newEvent.workPackages.map((wp) => wp.wbsElement.name).join(', ');
509508

510509
const projects = newEvent.workPackages.map((wp) => wp.project);
511510

512-
// Send a slack message to all members invited to the event
513-
for (const memberUserSetting of memberUserSettings) {
514-
if (memberUserSetting.slackId) {
515-
try {
516-
// For each project associated with this event
517-
for (const project of projects) {
518-
await sendSlackEventConfirmNotification(
519-
memberUserSetting.slackId,
520-
newEvent.eventId,
521-
newEvent.title,
522-
project.wbsElement.name
523-
);
524-
}
525-
} catch (err: unknown) {
526-
if (err instanceof Error) {
527-
throw new HttpException(500, `Failed to send slack notification: ${err.message}`);
511+
// Send a slack message to all members invited to the event if the event requires confirmation
512+
if (newEvent.status === Event_Status.UNCONFIRMED) {
513+
for (const memberUserSetting of memberUserSettings) {
514+
if (memberUserSetting.slackId) {
515+
try {
516+
// For each project associated with this event
517+
for (const project of projects) {
518+
await sendSlackEventConfirmNotification(
519+
memberUserSetting.slackId,
520+
newEvent.eventId,
521+
newEvent.title,
522+
project.wbsElement.name
523+
);
524+
}
525+
} catch (err: unknown) {
526+
if (err instanceof Error) {
527+
throw new HttpException(500, `Failed to send slack notification: ${err.message}`);
528+
}
528529
}
529530
}
530531
}
531532
}
532533

533-
if (newEvent.status === Event_Status.CONFIRMED) {
534-
await sendEventConfirmationToThread(newEvent.notificationSlackThreads, newEvent.userCreated);
535-
}
536-
537534
// Send popup notification
538535
await sendEventPopUp(newEvent, members, submitter, workPackageNames, organization.organizationId);
539536

src/backend/src/utils/slack.utils.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export const sendSlackEventConfirmNotification = async (
251251
) => {
252252
const isProduction = process.env.NODE_ENV === 'production';
253253
if (!isProduction && !DEV_TESTING_OVERRIDE) return; // don't send msgs unless in prod
254-
const msg = `You have been invited to the ${eventName} Design Review in project ${projectName}!`;
254+
const msg = `You have been invited to ${eventName} in project ${projectName}!`;
255255
const fullLink = isProduction
256256
? `https://finishlinebyner.com/calendar/event/${eventId}`
257257
: `http://localhost:3000/calendar/event/${eventId}`;
@@ -338,7 +338,7 @@ export const sendSlackEventNotification = async (
338338
if (process.env.NODE_ENV !== 'production' && !DEV_TESTING_OVERRIDE) return []; // don't send msgs unless in prod
339339
const msgs: { channelId: string; ts: string }[] = [];
340340
const fullMsg = `${message}`;
341-
const fullLink = `https://finishlinebyner.com/design-review-calendar`;
341+
const fullLink = `https://finishlinebyner.com/calendar`;
342342
const btnText = `View Calendar`;
343343
const notification = await sendMessage(team.slackId, fullMsg, fullLink, btnText);
344344
if (notification) msgs.push(notification);
@@ -355,7 +355,12 @@ export const sendSlackEventNotifications = async (
355355
) => {
356356
if (process.env.NODE_ENV !== 'production' && !DEV_TESTING_OVERRIDE) return []; // don't send msgs unless in prod
357357
const notifications: { channelId: string; ts: string }[] = [];
358-
const message = `:spiral_calendar_pad: Design Review for *${workPackageName}* is being scheduled by ${submitter.firstName} ${submitter.lastName} in project ${projectName}`;
358+
let message;
359+
if (workPackageName) {
360+
message = `:spiral_calendar_pad: ${event.title} for *${workPackageName}* is being scheduled by ${submitter.firstName} ${submitter.lastName} in project ${projectName}`;
361+
} else {
362+
message = `:spiral_calendar_pad: ${event.title} is being scheduled by ${submitter.firstName} ${submitter.lastName} in project ${projectName}`;
363+
}
359364

360365
const completion: Promise<void>[] = teams.map(async (team) => {
361366
const sentNotifications: { channelId: string; ts: string }[] = await sendSlackEventNotification(team, message);
@@ -447,9 +452,9 @@ export const sendEventScheduledSlackNotif = async (threads: SlackMessageThread[]
447452

448453
const location = zoomLink && inPersonLocation ? `${inPersonLocation} and ${zoomLink}` : inPersonLocation || zoomLink || '';
449454

450-
const msg = `:spiral_calendar_pad: Design Review for *${drName}* has been scheduled for *${drTime}* ${location} by ${drSubmitter}`;
455+
const msg = `:spiral_calendar_pad: ${event.title} for *${drName}* has been scheduled for *${drTime}* ${location} by ${drSubmitter}`;
451456
const docLink = event.questionDocumentLink ? `<${event.questionDocumentLink}|Doc Link>` : '';
452-
const threadMsg = `The Design Review has been Scheduled! \n` + docLink;
457+
const threadMsg = `This event has been Scheduled! \n` + docLink;
453458

454459
try {
455460
if (threads && threads.length !== 0) {

0 commit comments

Comments
 (0)