Permalink
Browse files

server alerts

  • Loading branch information...
Lemmmy committed Dec 4, 2016
1 parent 249436d commit 446c4cc6eeb09c335f26a560cc544a359e0da5ed
Showing with 43 additions and 9 deletions.
  1. +14 −0 src/controllers/addresses.js
  2. +25 −0 src/routes/addresses.js
  3. +0 −7 src/routes/transactions.js
  4. +4 −0 src/schemas.js
  5. +0 −2 src/webserver.js
@@ -69,6 +69,20 @@ AddressesController.getAddress = function(address) {
});
};
AddressesController.getAlert = function(privatekey) {
return new Promise(function(resolve, reject) {
var address = krist.makeV2Address(privatekey);
addresses.getAddress(address).then(function(result) {
if (!result) {
return reject(new errors.ErrorAddressNotFound());
}
resolve(result.alert);
}).catch(reject);
});
};
AddressesController.addressToJSON = function(address) {
return {
address: address.address.toLowerCase(),
View
@@ -71,6 +71,20 @@ module.exports = function(app) {
return;
}
if (req.query.alert) {
var from = krist.makeV2Address(req.query.alert);
addresses.getAddress(from).then(function(address) {
if (address) {
res.send(address.alert);
} else {
res.send('');
}
});
return;
}
if (typeof req.query.richapi !== 'undefined') {
addresses.getRich().then(function(results) {
var out = "";
@@ -194,6 +208,17 @@ module.exports = function(app) {
});
});
app.post('/addresses/alert', function(req, res) {
addressesController.getAlert(req.body.privatekey).then(function(alert) {
res.json({
ok: true,
alert: alert
});
}).catch(function(error) {
utils.sendErrorToRes(req, res, error);
});
});
/**
* @api {get} /addresses/rich List the richest addresses
* @apiName GetRichAddresses
@@ -151,8 +151,6 @@ module.exports = function(app) {
}
if (typeof req.query.pushtx2 !== 'undefined') {
console.log("a");
if (!req.query.amt || isNaN(req.query.amt)) {
return res.send('Error3');
}
@@ -168,12 +166,7 @@ module.exports = function(app) {
return res.send('Error5');
}
console.log("b");
addresses.verify(from, req.query.pkey).then(function(results) {
console.log("c");
var authed = results.authed;
var sender = results.address;
View
@@ -32,6 +32,10 @@ var Address = database.getSequelize().define('address', {
privatekey: {
type: Sequelize.STRING(64),
allowNull: true
},
alert: {
type: Sequelize.STRING(1024),
allowNull: true
}
}, {
timestamps: false
View
@@ -69,8 +69,6 @@ Webserver.init = function() {
next();
});
Webserver.express.use(morgan("combined"));
Webserver.express.use(express.static('static'));
Webserver.express.set('views', path.join(__dirname, '../views'));

0 comments on commit 446c4cc

Please sign in to comment.