@@ -118,7 +118,7 @@ export default class NotificationsService {
118118 }
119119
120120 /**
121- * Sends the design review slack notifications for all design reviews scheduled for today
121+ * Sends Slack notifications for all events scheduled for today whose event type has sendSlackNotifications enabled
122122 */
123123 static async sendEventSlackNotifications ( ) {
124124 const endOfToday = startOfDayTomorrow ( ) ;
@@ -142,6 +142,8 @@ export default class NotificationsService {
142142 optionalMembers : { include : { userSettings : true } } ,
143143 userCreated : { include : { userSettings : true } } ,
144144 scheduledTimes : true ,
145+ teams : true ,
146+ eventType : true ,
145147 workPackages : {
146148 include : {
147149 wbsElement : true ,
@@ -156,12 +158,18 @@ export default class NotificationsService {
156158 }
157159 } ) ;
158160
159- const desginReviewEventTeamMap = new Map < string , EventWithAttendees [ ] > ( ) ;
161+ const eventTeamMap = new Map < string , EventWithAttendees [ ] > ( ) ;
160162
161163 events . forEach ( ( event ) => {
162- // Get all unique teams from all work packages associated with this event
164+ // Collect unique team Slack IDs: first from teams directly on the event, then from work packages
163165 const teamSlackIds = new Set < string > ( ) ;
164166
167+ event . teams . forEach ( ( team ) => {
168+ if ( team . slackId ) {
169+ teamSlackIds . add ( team . slackId ) ;
170+ }
171+ } ) ;
172+
165173 event . workPackages . forEach ( ( workPackage ) => {
166174 workPackage . project . teams . forEach ( ( team ) => {
167175 if ( team . slackId ) {
@@ -171,7 +179,7 @@ export default class NotificationsService {
171179 } ) ;
172180
173181 teamSlackIds . forEach ( ( teamSlackId ) => {
174- const currentEvents = desginReviewEventTeamMap . get ( teamSlackId ) ;
182+ const currentEvents = eventTeamMap . get ( teamSlackId ) ;
175183 const eventWithAttendees = {
176184 ...event ,
177185 attendees : event . requiredMembers . concat ( event . optionalMembers ) . concat ( event . userCreated ) ,
@@ -181,20 +189,20 @@ export default class NotificationsService {
181189 if ( currentEvents ) {
182190 currentEvents . push ( eventWithAttendees ) ;
183191 } else {
184- desginReviewEventTeamMap . set ( teamSlackId , [ eventWithAttendees ] ) ;
192+ eventTeamMap . set ( teamSlackId , [ eventWithAttendees ] ) ;
185193 }
186194 } ) ;
187195 } ) ;
188196
189- // Send the notifications to each team for their respective design reviews
190- const promises = Array . from ( desginReviewEventTeamMap ) . map ( async ( [ slackId , events ] ) => {
197+ // Send the notifications to each team for their respective events
198+ const promises = Array . from ( eventTeamMap ) . map ( async ( [ slackId , events ] ) => {
191199 const messageBlock = events
192200 . map ( ( event ) => {
193201 const zoomLink = event . zoomLink ? `<${ event . zoomLink } |Zoom Link>\n` : '' ;
194202 const questionDocLink = event . questionDocumentLink ? `<${ event . questionDocumentLink } |Question Doc Link>\n` : '' ;
195203
196- // Get work package names for this event
197204 const workPackageNames = event . workPackages . map ( ( wp ) => wp . wbsElement . name ) . join ( ', ' ) ;
205+ const workPackagesPart = workPackageNames ? ` (${ workPackageNames } )` : '' ;
198206
199207 // Get the earliest scheduled start time for display
200208 const [ earliestSlot ] = event . scheduledTimes
@@ -203,17 +211,17 @@ export default class NotificationsService {
203211 const timeDisplay = earliestSlot ? formatTimeForSlack ( new Date ( earliestSlot . startTime ! ) ) : 'TBD' ;
204212
205213 return (
206- `${ usersToSlackPings ( event . attendees ?? [ ] ) } ${ event . title } ( ${ workPackageNames } ) ` +
214+ `${ usersToSlackPings ( event . attendees ?? [ ] ) } * ${ event . eventType . name } *: ${ event . title } ${ workPackagesPart } ` +
207215 `will be having an event today at ${ timeDisplay } ET! ` +
208216 zoomLink +
209217 questionDocLink
210218 ) ;
211219 } )
212220 . join ( '\n\n' ) ;
213221
214- // messageBlock will be empty if there are design reviews with no attendees
222+ // messageBlock will be empty if there are events with no attendees
215223 if ( messageBlock !== '' )
216- await sendMessage ( slackId , ':calendar: :clock9: Upcoming Design Reviews ! :clock9: :calendar: \n\n\n' + messageBlock ) ;
224+ await sendMessage ( slackId , ':calendar: :clock9: Upcoming Events ! :clock9: :calendar: \n\n\n' + messageBlock ) ;
217225 } ) ;
218226
219227 await Promise . all ( promises ) ;
0 commit comments