@@ -13,8 +13,7 @@ import {
1313 Calendar ,
1414 FilterArgs ,
1515 Machinery ,
16- ScheduleSlot ,
17- notGuest
16+ ScheduleSlot
1817} from 'shared' ;
1918import { getCalendarQueryArgs } from '../prisma-query-args/calendar.query-args.js' ;
2019import { getEventTypeQueryArgs } from '../prisma-query-args/event-type.query-args.js' ;
@@ -65,7 +64,7 @@ import {
6564 updateUserAvailability ,
6665 areUsersinList
6766} from '../utils/users.utils.js' ;
68- import { Conflict_Status , Event_Status , Organization } from '@prisma/client' ;
67+ import { Conflict_Status , Event_Status , Organization , Team } from '@prisma/client' ;
6968
7069export default class CalendarService {
7170 /**
@@ -286,7 +285,7 @@ export default class CalendarService {
286285 if ( ! hasPermission ) {
287286 throw new AccessDeniedException ( 'Only admins and heads can create events under this event type' ) ;
288287 }
289- } else if ( notGuest ( submitter . role ) ) {
288+ } else if ( isGuest ( submitter . role ) ) {
290289 throw new AccessDeniedGuestException ( 'Guests cannot create events' ) ;
291290 }
292291
@@ -497,10 +496,6 @@ export default class CalendarService {
497496 where : { userId : { in : optionalMemberIds . concat ( requiredMemberIds ) } }
498497 } ) ;
499498
500- if ( ! members ) {
501- throw new NotFoundException ( 'User' , 'Cannot find members who are invited to the design review' ) ;
502- }
503-
504499 // get the user settings for all the members invited, who are leaderingship
505500 const memberUserSettings = await prisma . user_Settings . findMany ( {
506501 where : { userId : { in : members . map ( ( member ) => member . userId ) } }
@@ -527,18 +522,24 @@ export default class CalendarService {
527522 // Send popup notification
528523 await sendEventPopUp ( newEvent , members , submitter , workPackageNames , organization . organizationId ) ;
529524
525+ const teamsToNotify = new Set < Team > ( ) ;
530526 for ( const project of projects ) {
531- const projectTeams = project . teams ;
532- if ( projectTeams . length > 0 ) {
533- await sendSlackEventNotifications (
534- projectTeams ,
535- createdEvent ,
536- submitter ,
537- workPackageNames ,
538- project . wbsElement . name
539- ) ;
527+ for ( const team of project . teams ) {
528+ teamsToNotify . add ( team ) ;
540529 }
541530 }
531+
532+ for ( const team of newEvent . teams ) {
533+ teamsToNotify . add ( team ) ;
534+ }
535+
536+ await sendSlackEventNotifications (
537+ Array . from ( teamsToNotify ) ,
538+ createdEvent ,
539+ submitter ,
540+ workPackageNames ,
541+ organization . name
542+ ) ;
542543 }
543544
544545 return createdEvent ;
0 commit comments