@@ -147,22 +147,16 @@ export const sendReimbursementRequestCreatedNotificationAndCreateMessageInfo = a
147147
148148 if ( ! financeTeam ) throw new HttpException ( 500 , 'Finance team does not exist!' ) ;
149149
150- try {
151- const messageInfo = await sendMessage ( financeTeam . slackId , msg , link , linkButtonText ) ;
152- if ( ! messageInfo ) return ; // Not on prod
153-
154- await prisma . message_Info . create ( {
155- data : {
156- reimbursementRequestId : requestId ,
157- channelId : messageInfo . channelId ,
158- timestamp : messageInfo . ts
159- }
160- } ) ;
161- } catch ( error : unknown ) {
162- if ( error instanceof Error ) {
163- throw new HttpException ( 500 , `Failed to send slack notification: ${ error . message } ` ) ;
150+ const messageInfo = await sendMessage ( financeTeam . slackId , msg , link , linkButtonText ) ;
151+ if ( ! messageInfo ) return ;
152+
153+ await prisma . message_Info . create ( {
154+ data : {
155+ reimbursementRequestId : requestId ,
156+ channelId : messageInfo . channelId ,
157+ timestamp : messageInfo . ts
164158 }
165- }
159+ } ) ;
166160} ;
167161
168162/**
@@ -177,26 +171,14 @@ export const sendReimbursementRequestDeniedNotification = async (slackId: string
177171 const link = `https://finishlinebyner.com/finance/reimbursement-requests/${ requestId } ` ;
178172 const linkButtonText = 'View Reimbursement Request' ;
179173
180- try {
181- await sendMessage ( slackId , msg , link , linkButtonText ) ;
182- } catch ( error : unknown ) {
183- if ( error instanceof Error ) {
184- throw new HttpException ( 500 , `Failed to send slack notification: ${ error . message } ` ) ;
185- }
186- }
174+ await sendMessage ( slackId , msg , link , linkButtonText ) ;
187175} ;
188176
189177export const sendThreadResponse = async ( threads : SlackMessageThread [ ] , message : string ) => {
190178 if ( process . env . NODE_ENV !== 'production' && ! DEV_TESTING_OVERRIDE ) return ; // don't send msgs unless in prod
191- try {
192- if ( threads && threads . length !== 0 ) {
193- const msgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , message ) ) ;
194- await Promise . all ( msgs ) ;
195- }
196- } catch ( err : unknown ) {
197- if ( err instanceof Error ) {
198- throw new HttpException ( 500 , `Failed to send slack notifications: ${ err . message } ` ) ;
199- }
179+ if ( threads && threads . length !== 0 ) {
180+ const msgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , message ) ) ;
181+ await Promise . all ( msgs ) ;
200182 }
201183} ;
202184
@@ -257,13 +239,7 @@ export const sendSlackEventConfirmNotification = async (
257239 : `http://localhost:3000/calendar/event/${ eventId } ` ;
258240 const linkButtonText = 'Confirm Availability' ;
259241
260- try {
261- await sendMessage ( slackId , msg , fullLink , linkButtonText ) ;
262- } catch ( error : unknown ) {
263- if ( error instanceof Error ) {
264- throw new HttpException ( 500 , `Failed to send slack notification: ${ error . message } ` ) ;
265- }
266- }
242+ await sendMessage ( slackId , msg , fullLink , linkButtonText ) ;
267243} ;
268244
269245/**
@@ -390,31 +366,19 @@ export const sendEventUserConfirmationToThread = async (threads: SlackMessageThr
390366 if ( process . env . NODE_ENV !== 'production' && ! DEV_TESTING_OVERRIDE ) return ; // don't send msgs unless in prod
391367 const slackPing = userToSlackPing ( submitter ) ;
392368 const fullMsg = `${ slackPing } confirmed their availability!` ;
393- try {
394- if ( threads && threads . length !== 0 ) {
395- const msgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , fullMsg ) ) ;
396- await Promise . all ( msgs ) ;
397- }
398- } catch ( err : unknown ) {
399- if ( err instanceof Error ) {
400- throw new HttpException ( 500 , `Failed to send slack notification: ${ err . message } ` ) ;
401- }
369+ if ( threads && threads . length !== 0 ) {
370+ const msgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , fullMsg ) ) ;
371+ await Promise . all ( msgs ) ;
402372 }
403373} ;
404374
405375export const sendEventConfirmationToThread = async ( threads : SlackMessageThread [ ] , submitter : UserWithSettings ) => {
406376 if ( process . env . NODE_ENV !== 'production' && ! DEV_TESTING_OVERRIDE ) return ; // don't send msgs unless in prod
407377 const slackPing = userToSlackPing ( submitter ) ;
408378 const fullMsg = `${ slackPing } All of the required attendees have confirmed their availability!` ;
409- try {
410- if ( threads && threads . length !== 0 ) {
411- const msgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , fullMsg ) ) ;
412- await Promise . all ( msgs ) ;
413- }
414- } catch ( err : unknown ) {
415- if ( err instanceof Error ) {
416- throw new HttpException ( 500 , `Failed to send slack notification: ${ err . message } ` ) ;
417- }
379+ if ( threads && threads . length !== 0 ) {
380+ const msgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , fullMsg ) ) ;
381+ await Promise . all ( msgs ) ;
418382 }
419383} ;
420384
@@ -456,19 +420,13 @@ export const sendEventScheduledSlackNotif = async (threads: SlackMessageThread[]
456420 const docLink = event . questionDocumentLink ? `<${ event . questionDocumentLink } |Doc Link>` : '' ;
457421 const threadMsg = `This event has been Scheduled! \n` + docLink ;
458422
459- try {
460- if ( threads && threads . length !== 0 ) {
461- const msgs = threads . map ( ( thread ) => editMessage ( thread . channelId , thread . timestamp , msg ) ) ;
462- await Promise . all ( msgs ) ;
463- const threadMsgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , threadMsg ) ) ;
464- await Promise . all ( threadMsgs ) ;
465- const reactions = threads . map ( ( thread ) => reactToMessage ( thread . channelId , thread . timestamp , 'calendar' ) ) ;
466- await Promise . all ( reactions ) ;
467- }
468- } catch ( err : unknown ) {
469- if ( err instanceof Error ) {
470- throw new HttpException ( 500 , `Failed to send slack notification: ${ err . message } ` ) ;
471- }
423+ if ( threads && threads . length !== 0 ) {
424+ const msgs = threads . map ( ( thread ) => editMessage ( thread . channelId , thread . timestamp , msg ) ) ;
425+ await Promise . all ( msgs ) ;
426+ const threadMsgs = threads . map ( ( thread ) => replyToMessageInThread ( thread . channelId , thread . timestamp , threadMsg ) ) ;
427+ await Promise . all ( threadMsgs ) ;
428+ const reactions = threads . map ( ( thread ) => reactToMessage ( thread . channelId , thread . timestamp , 'calendar' ) ) ;
429+ await Promise . all ( reactions ) ;
472430 }
473431} ;
474432
@@ -509,20 +467,14 @@ export const sendSlackCRStatusToThread = async (
509467 const fullMsg = `This Change Request was ${ approved ? 'approved! :tada:' : 'denied.' } Click the link to view.` ;
510468 const fullLink = `https://finishlinebyner.com/cr/${ crId } ` ;
511469 const btnText = `View CR#${ identifier } ` ;
512- try {
513- if ( threads && threads . length !== 0 ) {
514- const msgs = threads . map ( ( thread ) =>
515- replyToMessageInThread ( thread . channelId , thread . timestamp , fullMsg , fullLink , btnText )
516- ) ;
517- const reactions = threads . map ( ( thread ) =>
518- reactToMessage ( thread . channelId , thread . timestamp , approved ? 'white_check_mark' : 'x' )
519- ) ;
520- await Promise . all ( [ ...msgs , ...reactions ] ) ;
521- }
522- } catch ( err : unknown ) {
523- if ( err instanceof Error ) {
524- throw new HttpException ( 500 , `Failed to send slack notification: ${ err . message } ` ) ;
525- }
470+ if ( threads && threads . length !== 0 ) {
471+ const msgs = threads . map ( ( thread ) =>
472+ replyToMessageInThread ( thread . channelId , thread . timestamp , fullMsg , fullLink , btnText )
473+ ) ;
474+ const reactions = threads . map ( ( thread ) =>
475+ reactToMessage ( thread . channelId , thread . timestamp , approved ? 'white_check_mark' : 'x' )
476+ ) ;
477+ await Promise . all ( [ ...msgs , ...reactions ] ) ;
526478 }
527479} ;
528480
0 commit comments