Skip to content

Commit d759a1d

Browse files
committed
GravatarAdd ability to disable the sending of the push notifications via a options.disabled.
Disabled all logging if `options.debug` is not set to true. Commit: cb280fe [cb280fe] Parents: a8ff9e3 Author: Chris Spiegl <chris@spiegl.io> Date: November 5, 2017 at 01:31:19 GMT+7 Labels: HEAD -> master
1 parent cb280fe commit d759a1d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

index.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'development';
33
const request = require('request-promise-native');
44

55
function sendRequest(namespace, text, level='INFO', options={}) {
6+
if (options.disabled == true) {
7+
if (options.debug) console.log('PushNotice: disabled not sending the notification');
8+
return;
9+
}
610
if (options.chat == undefined) {
7-
console.error('PushNotice: chat object has to be provided');
11+
if (options.debug) console.error('PushNotice: chat object has to be provided');
812
return;
913
}
1014
if (options.chat && options.chat.id == undefined) {
11-
console.error('PushNotice: chat id has to be provided');
15+
if (options.debug) console.error('PushNotice: chat id has to be provided');
1216
return;
1317
}
1418
if (options.chat && options.chat.secret == undefined) {
15-
console.error('PushNotice: chat secret has to be provided');
19+
if (options.debug) console.error('PushNotice: chat secret has to be provided');
1620
return;
1721
}
1822
if (namespace == undefined) {
19-
console.error('PushNotice: namespace has to be provided');
23+
if (options.debug) console.error('PushNotice: namespace has to be provided');
2024
return;
2125
}
2226
if (text == undefined) {
23-
console.error('PushNotice: text has to be provided');
27+
if (options.debug) console.error('PushNotice: text has to be provided');
2428
return;
2529
}
2630
if (level == undefined) {
27-
console.error('PushNotice: level has to be provided');
31+
if (options.debug) console.error('PushNotice: level has to be provided');
2832
return;
2933
}
3034
if (options.url == undefined) options.url = 'https://pushnotice.chat/api/v1/chatnotice';

0 commit comments

Comments
 (0)