File size: 732 Bytes
e1d589b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | /**
* @module ratbird
*/
var Notifier = require('./lib/notifier');
var through = require('through');
var blindfold = require('blindfold');
module.exports.createNotifier = function(config) {
return new Notifier(config);
};
module.exports.createDispatchStream = function(config) {
if (!config.preferencesPath) {
throw new Error('Cannot create astream without `preferencePath`');
}
var notifier = new Notifier(config);
return through(function(activity) {
var prefs = blindfold(activity, config.preferencesPath);
if (!prefs) {
return this.queue(activity);
}
notifier.dispatch(activity, prefs);
this.queue(notifier._populateContent(activity));
});
};
module.exports.Notifier = Notifier;
|