Skip to content

Commit

Permalink
Process lebab arrow rule
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewchilds committed Nov 29, 2018
1 parent 99ccf1b commit dd68f24
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions slack-notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ slack.send({
const request = require('request');
const _ = require('lodash');

module.exports = function (url) {
module.exports = url => {
const pub = {};

pub.request = function (data, done) {
pub.request = (data, done) => {
if (!url) {
console.log('No Slack URL configured.');
return false;
Expand All @@ -44,7 +44,7 @@ module.exports = function (url) {
form: {
payload: JSON.stringify(data)
}
}, function(err, response) {
}, (err, response) => {
if (err) {
pub.onError(err);
return done(err);
Expand All @@ -58,7 +58,7 @@ module.exports = function (url) {
});
};

pub.send = function (options, done) {
pub.send = (options, done) => {
if (_.isString(options)) {
options = { text: options };
}
Expand All @@ -79,13 +79,11 @@ module.exports = function (url) {

data.attachments.push({
fallback: 'Alert details',
fields: _.map(options.fields, function (value, title) {
return {
title: title,
value: value,
short: (value + '').length < 25
};
})
fields: _.map(options.fields, (value, title) => ({
title: title,
value: value,
short: (value + '').length < 25
}))
});

delete(data.fields);
Expand All @@ -99,14 +97,12 @@ module.exports = function (url) {
pub.request(data, done);
};

pub.extend = function (defaults) {
return function (options, done) {
if (_.isString(options)) {
options = { text: options };
}
pub.extend = defaults => (options, done) => {
if (_.isString(options)) {
options = { text: options };
}

pub.send(_.extend({}, defaults, options), done);
};
pub.send(_.extend({}, defaults, options), done);
};

pub.bug = pub.extend({
Expand Down

0 comments on commit dd68f24

Please sign in to comment.