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.5 to 0.1.6

156

lib/pushover.js

@@ -1,7 +0,7 @@

var https = require( 'https' ),
url = require( 'url' ),
qs = require( 'querystring' ),
p_url = 'https://api.pushover.net/1/messages.json';
var https = require('https'),
url = require('url'),
qs = require('querystring'),
p_url = 'https://api.pushover.net/1/messages.json';
function setDefaults( o ) {
function setDefaults(o) {
var def = [

@@ -12,3 +12,3 @@ 'priority',

'timestamp',
'sound',
'sound',
'url_title'

@@ -18,5 +18,5 @@ ];

var i = 0; l = def.length;
for ( ; i < l; i++ ) {
if ( ! o[ def[i] ] ) {
o[ def[i] ] = '';
for (; i < l; i++) {
if (!o[def[i]]) {
o[def[i]] = '';
}

@@ -28,69 +28,71 @@ }

function Pushover( opts ) {
var self = this;
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)"
};
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 ) {
if (opts.debug) {
this.debug = opts.debug;
}
self.updateSounds();
setTimeout( function() {
self.updateSounds();
}, 86400000 );
self.updateSounds();
if (opts.update_sounds) {
setInterval(function() {
self.updateSounds();
}, 86400000);
}
};
Pushover.prototype.errors = function( d ) {
if ( typeof d === 'string' ) {
d = JSON.parse( d );
}
Pushover.prototype.errors = function(d) {
if (typeof d === 'string') {
d = JSON.parse(d);
}
if ( d.errors ) {
throw new Error( d.errors[0] );
}
if (d.errors) {
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 ) {
res.on('data', function(chunk) {
data += chunk;
});
res.on( 'error', function( e ) {
res.on('error', function(e) {
err = e;
});
});
});
req.write('');

@@ -100,12 +102,12 @@ req.end();

Pushover.prototype.send = function( obj, fn ) {
Pushover.prototype.send = function(obj, fn) {
var self = this;
var o = url.parse( p_url );
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';
}

@@ -118,7 +120,7 @@ var req_string = {

var p;
for ( p in obj ) {
for (p in obj) {
req_string[ p ] = obj[p];
}
req_string = qs.stringify( req_string );
req_string = qs.stringify(req_string);

@@ -129,20 +131,20 @@ o.headers = {

var req = https.request( o, function( res ) {
if ( self.debug ) {
console.log( res.statusCode );
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('end', function() {
self.errors(data);
if (fn) {
fn.call(null, err, data);
}
});
res.on( 'data', function( chunk ) {
res.on('data', function(chunk) {
data += chunk;
});
res.on( 'error', function( e ) {
res.on('error', function(e) {
err = e;

@@ -152,6 +154,6 @@ });

if ( self.debug ) {
console.log ( req_string );
if (self.debug) {
console.log (req_string);
}
req.write( req_string );
req.write(req_string);
req.end();

@@ -158,0 +160,0 @@ };

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

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

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

@@ -21,2 +21,4 @@ ![Pushover](https://pushover.net/assets/pushover-header-0f47af8e08d8bef658a999a9e6584fcc.png)

token: process.env['PUSHOVER_TOKEN'],
// update_sounds: true // update the list of sounds every day - will
// prevent app from exiting.
});

@@ -23,0 +25,0 @@

@@ -6,2 +6,3 @@ var push = require( '../lib/pushover.js' );

token: process.env['PUSHOVER_TOKEN'],
update_sounds: false,
debug: true

@@ -12,3 +13,3 @@ });

message: 'omg node test',
sound: 'magic',
sound: 'magic',
title: "Well - this is fantastic",

@@ -20,5 +21,5 @@ };

p.send( msg, function( err, result ) {
console.log( 'error', err );
console.log( 'result', result );
process.exit(0);
console.log( 'error', err );
console.log( 'result', result );
// process.exit(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