Repository navigation
#4411 activation slack message #4534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/change-request-buffer
Are you sure you want to change the base?
Changes from all commits
3849f66
6942caf
0ffc5c2
e6cfe42
4bb0ef4
48a4cf2
b997536
3067859
2cd1538
26a1565
f67ef1a
d8ee46a
778dd4a
9dac2eb
3398c5a
66ef547
f8d5f9a
9bb8dd7
c08e1d4
b64ec35
7527c65
80a0e1a
cf10e73
c410a78
175747b
7b6bace
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import { | |
| Team as SharedTeam, | ||
| TeamJoinRequest | ||
| } from 'shared'; | ||
| import { Account_Code, Organization, Reimbursement_Product_Other_Reason, Sponsor_Task } from '@prisma/client'; | ||
| import { Account_Code, Organization, Reimbursement_Product_Other_Reason, Sponsor_Task, Team_Type } from '@prisma/client'; | ||
| import { | ||
| editMessage, | ||
| getChannelName, | ||
|
|
@@ -23,7 +23,7 @@ import { | |
| sendEphemeralMessage, | ||
| sendMessage | ||
| } from '../integrations/slack.js'; | ||
| import { getUserSlackId, getUserSlackMentionOrName } from './users.utils.js'; | ||
| import { getUserSlackId, getUserSlackMentionOrName, getUsersWithSettings } from './users.utils.js'; | ||
| import prisma from '../prisma/prisma.js'; | ||
| import { HttpException } from './errors.utils.js'; | ||
| import { Change_Request, Team, WBS_Element } from '@prisma/client'; | ||
|
|
@@ -984,3 +984,59 @@ export const notifySponsorTaskAssignee = async ( | |
| const linkButtonText = `View Tasks for ${sponsor}`; | ||
| await sendMessage(assignee.userSettings?.slackId, msg, link, linkButtonText); | ||
| }; | ||
|
|
||
| /** | ||
| * Sends to team channels as well as leads and manager about | ||
| * a work package that is scheduled to start at a later date than anticipated | ||
| * | ||
| * @param teams The teams to notify | ||
| * @param leadId The work package's lead | ||
| * @param managerId The work package's manager | ||
| * @param startDate The planned starting date for the work package | ||
| * @param activationDate The actual starting date for the work package | ||
| * @param bufferDays The threshold that triggers this message | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not a param |
||
| * @param wbsString The wbs number as a string type | ||
| * @param name Name of the work package | ||
| */ | ||
|
Steph375 marked this conversation as resolved.
|
||
| export const sendActivationStartDateChangedNotification = async ( | ||
| teams: (Team & { teamType: Team_Type | null })[] | undefined, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this not just an array of teams? |
||
| leadId: string = '', | ||
| managerId: string = '', | ||
| startDate: Date, | ||
| activationDate: Date, | ||
| wbsString: string, | ||
| name: string | ||
| ) => { | ||
| const leadIdPing = (await pingBasedOnId(leadId)) || ''; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather use getUserSlackMentionOrName |
||
| const managerIdPing = (await pingBasedOnId(managerId)) || ''; | ||
|
|
||
| const activationDateString = activationDate.toDateString(); | ||
| const startDateString = startDate.toDateString(); | ||
|
|
||
|
Steph375 marked this conversation as resolved.
|
||
| const message = | ||
| leadIdPing + | ||
| ' ' + | ||
| managerIdPing + | ||
| ' The start date for ' + | ||
| name + | ||
| ' has been changed from ' + | ||
| startDateString + | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pretty sure the two start dates need to be swapped |
||
| ' to ' + | ||
| activationDateString + | ||
| '.\n'; | ||
| const link = `https://finishlinebyner.com/projects/${wbsString}`; | ||
| const linkButtonText = 'Change Work Package'; | ||
|
|
||
| await Promise.all(teams?.map((team) => sendMessage(team.slackId, message, link, linkButtonText)) ?? []); | ||
| }; | ||
|
|
||
| async function pingBasedOnId(id: string) { | ||
| if (id) { | ||
|
Steph375 marked this conversation as resolved.
|
||
| const [user] = await getUsersWithSettings([id]); | ||
| if (user) { | ||
| const ping = userToSlackPing(user); | ||
| if (ping) return ping; | ||
| } | ||
| } | ||
| return ''; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this only sends to the team channels pinging the lead and manager