Fix repeated review Slack notifications
This commit is contained in:
parent
837c7a27eb
commit
da5667090c
|
@ -23,19 +23,18 @@ function registerForNewReviewRequests (robot, getSlackIdFromGitHubId) {
|
|||
// Make sure we don't listen to our own messages
|
||||
if (context.isBot) return null
|
||||
|
||||
await notifyReviewers(context, robot, getSlackIdFromGitHubId)
|
||||
await notifyReviewer(context, robot, getSlackIdFromGitHubId)
|
||||
})
|
||||
}
|
||||
|
||||
async function notifyReviewers (context, robot, getSlackIdFromGitHubId) {
|
||||
async function notifyReviewer (context, robot, getSlackIdFromGitHubId) {
|
||||
const { payload } = context
|
||||
|
||||
for (let reviewer of payload.pull_request.requested_reviewers) {
|
||||
const reviewer = payload.requested_reviewer
|
||||
const userID = getSlackIdFromGitHubId(reviewer.login)
|
||||
|
||||
if (!userID) {
|
||||
robot.log.warn('Could not find Slack ID for GitHub user', reviewer.login)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
slackWeb.im.open(userID).then(resp => {
|
||||
|
@ -48,4 +47,3 @@ async function notifyReviewers (context, robot, getSlackIdFromGitHubId) {
|
|||
slackWeb.chat.postMessage(dmChannelID, msg, {unfurl_links: true, as_user: slackHelper.BotUserName})
|
||||
}).catch(error => robot.log.error('Could not open DM channel for review request notification', error))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue