mirror of
https://github.com/status-im/status-github-bot.git
synced 2025-01-14 15:25:13 +00:00
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
|
// Make sure we don't listen to our own messages
|
||||||
if (context.isBot) return null
|
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
|
const { payload } = context
|
||||||
|
const reviewer = payload.requested_reviewer
|
||||||
for (let reviewer of payload.pull_request.requested_reviewers) {
|
|
||||||
const userID = getSlackIdFromGitHubId(reviewer.login)
|
const userID = getSlackIdFromGitHubId(reviewer.login)
|
||||||
|
|
||||||
if (!userID) {
|
if (!userID) {
|
||||||
robot.log.warn('Could not find Slack ID for GitHub user', reviewer.login)
|
robot.log.warn('Could not find Slack ID for GitHub user', reviewer.login)
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
slackWeb.im.open(userID).then(resp => {
|
slackWeb.im.open(userID).then(resp => {
|
||||||
@ -47,5 +46,4 @@ async function notifyReviewers (context, robot, getSlackIdFromGitHubId) {
|
|||||||
|
|
||||||
slackWeb.chat.postMessage(dmChannelID, msg, {unfurl_links: true, as_user: slackHelper.BotUserName})
|
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))
|
}).catch(error => robot.log.error('Could not open DM channel for review request notification', error))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user