From 14a74a5a8ccc6a1fac7b06076acefbd7191638d2 Mon Sep 17 00:00:00 2001 From: "Kees C. Bakker" Date: Tue, 29 Aug 2023 10:36:24 +0200 Subject: [PATCH] chore: refactor returns and ifs --- src/scripts/pagerduty-webhook.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/scripts/pagerduty-webhook.js b/src/scripts/pagerduty-webhook.js index e15c378..ca95cf8 100644 --- a/src/scripts/pagerduty-webhook.js +++ b/src/scripts/pagerduty-webhook.js @@ -12,7 +12,8 @@ module.exports = function (robot) { if (pagerEndpoint && pagerRoom) { robot.router.post(pagerEndpoint, function (req, res) { robot.messageRoom(pagerRoom, parseWebhook(req, res)); - return res.end(); + res.end(); + return; }); } @@ -42,15 +43,16 @@ module.exports = function (robot) { return returnMessage.join('\n'); }; - const getUserForIncident = function (incident) { + function getUserForIncident(incident) { if (incident.assigned_to_user) { return incident.assigned_to_user.email; - } else if (incident.resolved_by_user) { + } + if (incident.resolved_by_user) { return incident.resolved_by_user.email; - } else { - return '(???)'; } - }; + + return '(???)'; + } return (generateIncidentString = function (incident, hookType) { console.log('hookType is ' + hookType);