Replace use of promises by async/await in `notifyReviewer`

This commit is contained in:
Pedro Pombeiro 2018-02-14 12:39:00 +01:00
parent b6090f36a2
commit 7b565bf117
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
1 changed files with 6 additions and 2 deletions

View File

@ -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)
}
} }