Replace use of promises by async/await in `notifyReviewer`
This commit is contained in:
parent
b6090f36a2
commit
7b565bf117
|
@ -35,7 +35,9 @@ async function notifyReviewer (context, robot, getSlackIdFromGitHubId) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
robot.slackWeb.im.open(userID).then(resp => {
|
try {
|
||||||
|
const resp = await robot.slackWeb.im.open(userID)
|
||||||
|
|
||||||
const dmChannelID = resp.channel.id
|
const dmChannelID = resp.channel.id
|
||||||
const msg = `New Pull Request awaiting your review: ${payload.pull_request.html_url}`
|
const msg = `New Pull Request awaiting your review: ${payload.pull_request.html_url}`
|
||||||
|
|
||||||
|
@ -43,5 +45,7 @@ async function notifyReviewer (context, robot, getSlackIdFromGitHubId) {
|
||||||
robot.log.info(`Notifying ${userID} about review request in ${payload.pull_request.url}`)
|
robot.log.info(`Notifying ${userID} about review request in ${payload.pull_request.url}`)
|
||||||
|
|
||||||
robot.slackWeb.chat.postMessage(dmChannelID, msg, {unfurl_links: true, as_user: slackHelper.BotUserName})
|
robot.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…
Reference in New Issue