Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pushover-notifications

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pushover-notifications - npm Package Compare versions

Comparing version 0.1.9 to 0.2.0

.npmignore

240

lib/pushover.js

@@ -7,159 +7,159 @@ var https = require('https'),

function setDefaults(o) {
var def = [
'device',
'title',
'url',
'url_title',
'priority',
'timestamp',
'sound'
];
var def = [
'device',
'title',
'url',
'url_title',
'priority',
'timestamp',
'sound'
];
var i = 0; l = def.length;
for (; i < l; i++) {
if (!o[def[i]]) {
o[def[i]] = '';
}
var i = 0; l = def.length;
for (; i < l; i++) {
if (!o[def[i]]) {
o[def[i]] = '';
}
}
return o;
return o;
}
function Pushover(opts) {
var self = this;
this.token = opts.token;
this.user = opts.user;
this.sounds = {
"pushover":"Pushover (default)",
"bike":"Bike",
"bugle":"Bugle",
"cashregister":"Cash Register",
"classical":"Classical",
"cosmic":"Cosmic",
"falling":"Falling",
"gamelan":"Gamelan",
"incoming":"Incoming",
"intermission":"Intermission",
"magic":"Magic",
"mechanical":"Mechanical",
"pianobar":"Piano Bar",
"siren":"Siren",
"spacealarm":"Space Alarm",
"tugboat":"Tug Boat",
"alien":"Alien Alarm (long)",
"climb":"Climb (long)",
"persistent":"Persistent (long)",
"echo":"Pushover Echo (long)",
"updown":"Up Down (long)",
"none":"None (silent)"
};
var self = this;
this.token = opts.token;
this.user = opts.user;
this.sounds = {
"pushover":"Pushover (default)",
"bike":"Bike",
"bugle":"Bugle",
"cashregister":"Cash Register",
"classical":"Classical",
"cosmic":"Cosmic",
"falling":"Falling",
"gamelan":"Gamelan",
"incoming":"Incoming",
"intermission":"Intermission",
"magic":"Magic",
"mechanical":"Mechanical",
"pianobar":"Piano Bar",
"siren":"Siren",
"spacealarm":"Space Alarm",
"tugboat":"Tug Boat",
"alien":"Alien Alarm (long)",
"climb":"Climb (long)",
"persistent":"Persistent (long)",
"echo":"Pushover Echo (long)",
"updown":"Up Down (long)",
"none":"None (silent)"
};
if (opts.debug) {
this.debug = opts.debug;
}
if (opts.debug) {
this.debug = opts.debug;
}
if (opts.onerror) {
this.onerror = opts.onerror;
}
if (opts.onerror) {
this.onerror = opts.onerror;
}
if (opts.update_sounds) {
self.updateSounds();
if (opts.update_sounds) {
setInterval(function() {
self.updateSounds();
}, 86400000);
}
setInterval(function() {
self.updateSounds();
}, 86400000);
}
};
Pushover.prototype.errors = function(d) {
if (typeof d === 'string') {
d = JSON.parse(d);
}
if (typeof d === 'string') {
d = JSON.parse(d);
}
if (d.errors) {
if (this.onerror) {
this.onerror.call(null, d.errors[0])
} else {
throw new Error(d.errors[0]);
}
if (d.errors) {
if (this.onerror) {
this.onerror.call(null, d.errors[0])
} else {
throw new Error(d.errors[0]);
}
}
}
Pushover.prototype.updateSounds = function() {
var self = this, data = '';
var surl = 'https://api.pushover.net/1/sounds.json?token=' + self.token;
var req = https.request(url.parse(surl) , function(res) {
res.on('end', function() {
var j = JSON.parse(data);
self.errors(data);
self.sounds = j.sounds;
});
var self = this, data = '';
var surl = 'https://api.pushover.net/1/sounds.json?token=' + self.token;
var req = https.request(url.parse(surl) , function(res) {
res.on('end', function() {
var j = JSON.parse(data);
self.errors(data);
self.sounds = j.sounds;
});
res.on('data', function(chunk) {
data += chunk;
});
res.on('data', function(chunk) {
data += chunk;
});
res.on('error', function(e) {
err = e;
});
res.on('error', function(e) {
err = e;
});
req.write('');
req.end();
});
req.write('');
req.end();
};
Pushover.prototype.send = function(obj, fn) {
var self = this;
var o = url.parse(p_url);
o.method = "POST";
var self = this;
var o = url.parse(p_url);
o.method = "POST";
obj = setDefaults(obj);
obj = setDefaults(obj);
if (! self.sounds[ obj.sound ]) {
obj.sound = 'pushover';
}
if (! self.sounds[ obj.sound ]) {
obj.sound = 'pushover';
}
var req_string = {
token: self.token || obj.token,
user: self.user || obj.user
};
var req_string = {
token: self.token || obj.token,
user: self.user || obj.user
};
var p;
for (p in obj) {
req_string[ p ] = obj[p];
}
var p;
for (p in obj) {
req_string[ p ] = obj[p];
}
req_string = qs.stringify(req_string);
req_string = qs.stringify(req_string);
o.headers = {
'Content-Length': req_string.length
};
o.headers = {
'Content-Length': req_string.length
};
var req = https.request(o, function(res) {
if (self.debug) {
console.log(res.statusCode);
}
var err;
var data = '';
res.on('end', function() {
self.errors(data);
if (fn) {
fn.call(null, err, data);
}
});
var req = https.request(o, function(res) {
if (self.debug) {
console.log(res.statusCode);
}
var err;
var data = '';
res.on('end', function() {
self.errors(data);
if (fn) {
fn.call(null, err, data);
}
});
res.on('data', function(chunk) {
data += chunk;
});
res.on('data', function(chunk) {
data += chunk;
});
res.on('error', function(e) {
err = e;
});
res.on('error', function(e) {
err = e;
});
});
if (self.debug) {
console.log (req_string);
}
req.write(req_string);
req.end();
if (self.debug) {
console.log (req_string);
}
req.write(req_string);
req.end();
};
exports = module.exports = Pushover;

@@ -5,3 +5,3 @@ {

"description": "Pushover API for node.js",
"version": "0.1.9",
"version": "0.2.0",
"homepage": "http://github.com/qbit/node-pushover",

@@ -8,0 +8,0 @@ "repository": {

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