Socket
Socket
Sign inDemoInstall

@webgap/notifier

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@webgap/notifier - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

81

index.js

@@ -38,38 +38,39 @@ /**

module.exports.notify = function notify(options, callback) {
// handle notification systems
if (!options.notificationSystems) {
if (!defaultSystem) {
var error = new Error('No \'defaultSystem\' defined and no option \'notificationSystems\' provided.');
console.error(error.message);
return callback(error);
callback = callback || function noop() {
return;
};
if (options) {
// handle notification systems
if (!options.notificationSystems) {
if (!defaultSystem) {
return callback(new Error('No \'defaultSystem\' defined and no option \'notificationSystems\' provided.'));
} else {
options.notificationSystems = [defaultSystem];
}
} else {
if (!Array.isArray(options.notificationSystems)) {
options.notificationSystems = [options.notificationSystems];
}
}
else {
options.notificationSystems = [defaultSystem];
}
}
else {
if (!Array.isArray(options.notificationSystems)) {
options.notificationSystems = [options.notificationSystems];
}
}
// ensure the message is not delivered through the same system multiple times
options.notificationSystems = underscore.uniq(options.notificationSystems);
// notify using the requested systems
async.each(options.notificationSystems, function sendNotification(system, done) {
var instance = systems[system] ? systems[system].instance : null;
if (instance) {
try {
instance.notify(options.notification, function afterNotify(err) {
// ensure the message is not delivered through the same system multiple times
options.notificationSystems = underscore.uniq(options.notificationSystems);
// notify using the requested systems
async.each(options.notificationSystems, function sendNotification(system, done) {
var instance = systems[system] ? systems[system].instance : null;
if (instance) {
try {
instance.notify(options.notification, function afterNotify(err) {
return done(err);
});
} catch (err) {
return done(err);
});
}
} else {
console.warn('Trying to notify using a non registered system: %s', system);
return done();
}
catch (err) {
return done(err);
}
}
else {
console.warn('Trying to notify using a non registered system: %s', system);
return done();
}
}, callback);
}, callback);
} else {
return callback(new Error('No \'options\' provided. Cannot do anything from nothing.'));
}
};

@@ -90,5 +91,3 @@

if (system.instance && typeof system.instance.notify !== 'function') {
var error = new Error(util.format('The class provided must implement a \'notify\' function. Cannot register Notification System: %s', system.name));
console.error(error.message);
throw error;
throw new Error(util.format('The class provided must implement a \'notify\' function. Cannot register Notification System: %s', system.name));
}

@@ -103,3 +102,3 @@ if (systems[system.name]) {

systems[system.name].default = Boolean(system.defaultSystem) ? system.defaultSystem : false;
console.info('Notification system registered: %s.', system.name);
console.info('%s notification system registered.', system.name);
if (systems[system.name].default) {

@@ -113,9 +112,9 @@ defaultSystem = system.name;

/**
* Unregisters a Notification System
* Unregister a Notification System
*
* @param {string} systemName the name of the system
* @param {string} systemName the name of the system to unregister
*/
module.exports.unregister = function register(systemName) {
module.exports.unregister = function unregister(systemName) {
delete systems[systemName];
console.info('Notification system unregistered: %s.', systemName);
console.info('%s notification system unregistered.', systemName);
};
{
"name": "@webgap/notifier",
"description": "Webgap Notifications Manager.",
"description": "Webgap abstraction notification module.",
"author": "Manuel Martins <manuelmachadomartins@gmail.com>",
"version": "0.1.5",
"version": "0.1.6",
"license": "Apache-2.0",

@@ -7,0 +7,0 @@ "engine": "node >= 5.0.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc