Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve slack home, add additional sections for prs waiting for…
… review
- Loading branch information
1 parent
cc7d81d
commit f296ffa
Showing
18 changed files
with
390 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import type { RepoContext } from 'src/context/repoContext'; | ||
import type { AccountEmbedWithoutType } from '../../../../mongo'; | ||
import type { PullRequestWithDecentData } from '../../utils/PullRequestData'; | ||
|
||
interface UpdateSlackHomeForPrOptions { | ||
user?: boolean; | ||
assignees?: boolean; | ||
requestedReviewers?: boolean; | ||
requestedTeams?: boolean; | ||
teamMembers?: AccountEmbedWithoutType[]; | ||
otherLogins?: string[]; | ||
} | ||
|
||
export function updateSlackHomeForPr( | ||
repoContext: RepoContext, | ||
pullRequest: PullRequestWithDecentData, | ||
{ | ||
user, | ||
assignees, | ||
requestedReviewers, | ||
requestedTeams, | ||
teamMembers, | ||
otherLogins, | ||
}: UpdateSlackHomeForPrOptions, | ||
): void { | ||
if (repoContext.slack) { | ||
const logins = new Set<string>(otherLogins); | ||
|
||
if (user && pullRequest.user) { | ||
logins.add(pullRequest.user.login); | ||
} | ||
if (assignees && pullRequest.assignees) { | ||
pullRequest.assignees.forEach((assignee) => { | ||
logins.add(assignee.login); | ||
}); | ||
} | ||
|
||
if (requestedReviewers && pullRequest.requested_reviewers) { | ||
pullRequest.requested_reviewers.forEach((requestedReviewer) => { | ||
if (!('login' in requestedReviewer)) return; | ||
logins.add(requestedReviewer.login); | ||
}); | ||
} | ||
|
||
if (requestedTeams && pullRequest.requested_teams && teamMembers) { | ||
teamMembers.forEach((member) => { | ||
logins.add(member.login); | ||
}); | ||
} | ||
|
||
logins.forEach((login) => { | ||
repoContext.slack.updateHome(login); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.