Comparing version 1.0.50 to 1.0.51
@@ -78,8 +78,4 @@ "use strict"; | ||
yield Promise.all(alerts.map((alert) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
alert.removeMuted(config.muteWindows); | ||
alert.resolve(); | ||
if (alert.size === 0) { | ||
if (alert.isMuted) { | ||
yield sendMutedAlert(config, alert); | ||
} | ||
return; | ||
@@ -86,0 +82,0 @@ } |
@@ -100,3 +100,3 @@ "use strict"; | ||
success: false, | ||
msg: `Expected status:${expectedStatus},received ${status}` | ||
msg: `Expected status:${expectedStatus}, got ${status}` | ||
}; | ||
@@ -103,0 +103,0 @@ } |
@@ -19,3 +19,3 @@ "use strict"; | ||
while (true) { | ||
const result = yield doLoop(runner); | ||
const result = yield doLoop(args, runner); | ||
if (result < 0) { | ||
@@ -36,3 +36,3 @@ return result; | ||
} | ||
function doLoop(runner) { | ||
function doLoop(args, runner) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
@@ -45,3 +45,4 @@ const clock = (0, profiler_1.startClock)(); | ||
} | ||
const timeToSleep = exports.LoopMs - ms; | ||
const interval = args.debug ? 5000 : exports.LoopMs; | ||
const timeToSleep = interval - ms; | ||
yield (0, sleep_1.sleepMs)(timeToSleep < 0 ? 0 : timeToSleep); | ||
@@ -48,0 +49,0 @@ return result; |
@@ -28,3 +28,3 @@ "use strict"; | ||
sendMutedAlert(alert) { | ||
const message = `${this.prefix} π Alerts muted at ${alert.endTime}. ${this.postfix}`.trim(); | ||
const message = `${this.prefix} π Outage muted at ${alert.endTime}. ${this.postfix}`.trim(); | ||
console.log(message); | ||
@@ -31,0 +31,0 @@ return Promise.resolve(); |
@@ -19,2 +19,3 @@ import { Snapshot } from "../snapshot"; | ||
postToSlack(message: string, state?: any, reply?: boolean): Promise<any>; | ||
private reactToSlackMessage; | ||
} |
@@ -130,3 +130,4 @@ "use strict"; | ||
this.postToSlack(this.generateMessage([], alert), alert.state), | ||
this.postToSlack(`β <!channel> Previous outage resolved at ${alert.endTime}. Duration was ${alert.durationHuman}.\n_See above for more details about affected services._`, alert.state, true) | ||
this.postToSlack(`β <!channel> Previous outage resolved at ${alert.endTime}. Duration was ${alert.durationHuman}.\n_See above for more details about affected services._`, alert.state, true), | ||
this.reactToSlackMessage(alert.state, "white_check_mark") | ||
]); | ||
@@ -139,3 +140,4 @@ }); | ||
this.postToSlack(this.generateMessage([], alert), alert.state), | ||
this.postToSlack(`π <!channel> Affected alerts were muted at ${alert.endTime}.\n_See above for more details about affected services._`, alert.state, true) | ||
this.postToSlack(`π <!channel> Affected alerts were muted at ${alert.endTime}.\n_See above for more details about affected services._`, alert.state, true), | ||
this.reactToSlackMessage(alert.state, "no_bell") | ||
]); | ||
@@ -191,4 +193,35 @@ }); | ||
} | ||
reactToSlackMessage(state, reaction) { | ||
var _a; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
if (!state) { | ||
return; | ||
} | ||
const body = { | ||
name: reaction, | ||
channel: (_a = state === null || state === void 0 ? void 0 : state.channel) !== null && _a !== void 0 ? _a : this.channel, | ||
timestamp: state.ts | ||
}; | ||
const config = { | ||
method: 'post', | ||
url: "https://slack.com/api/reactions.add", | ||
headers: { | ||
'Authorization': `Bearer ${this.token}`, | ||
'Content-type': 'application/json;charset=utf-8', | ||
'Accept': '*/*', | ||
}, | ||
data: JSON.stringify(body) | ||
}; | ||
try { | ||
const result = yield axios_1.default.request(config); | ||
console.log(result); | ||
} | ||
catch (err) { | ||
const msg = `Error posting to Slack: ${err.message}`; | ||
(0, logger_1.log)(msg, err); | ||
} | ||
}); | ||
} | ||
} | ||
exports.SlackChannelConfig = SlackChannelConfig; | ||
//# sourceMappingURL=slack.js.map |
{ | ||
"name": "barky", | ||
"version": "1.0.50", | ||
"version": "1.0.51", | ||
"description": "A simple cloud services watchdog with digest notification support & no external dependencies", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Rohland/barky#readme", |
{ | ||
"name": "barky", | ||
"version": "1.0.50", | ||
"version": "1.0.51", | ||
"description": "A simple cloud services watchdog with digest notification support & no external dependencies", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/Rohland/barky#readme", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
331268
4470