diff --git a/SQL_MIGRATIONS.md b/SQL_MIGRATIONS.md index 043b39c..5c8a729 100644 --- a/SQL_MIGRATIONS.md +++ b/SQL_MIGRATIONS.md @@ -26,4 +26,10 @@ ALTER TABLE pool.shapeshiftTxn CONVERT TO CHARACTER SET utf8 COLLATE utf8_genera ALTER TABLE pool.transactions CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE pool.users CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; ALTER TABLE pool.xmrtoTxn CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci; +``` + +2/25/2017 +--------- +```sql +ALTER TABLE monero_live.users ADD enable_email BOOL DEFAULT true NULL; ``` \ No newline at end of file diff --git a/lib/api.js b/lib/api.js index 9bd1781..20b9ea2 100644 --- a/lib/api.js +++ b/lib/api.js @@ -486,8 +486,8 @@ secureRoutes.get('/tokenRefresh', function (req, res) { }); secureRoutes.get('/', function (req, res) { - global.mysql.query("SELECT payout_threshold FROM users WHERE id = ?", [req.decoded.id]).then(function(row){ - return res.json({msg: row[0].payout_threshold}); + global.mysql.query("SELECT payout_threshold, enable_email FROM users WHERE id = ?", [req.decoded.id]).then(function(row){ + return res.json({msg: {payout_threshold: row[0].payout_threshold, email_enabled: row[0].enable_email}}); }); }); @@ -498,6 +498,12 @@ secureRoutes.post('/changePassword', function (req, res) { }); }); +secureRoutes.post('/toggleEmail', function (req, res) { + global.mysql.query("UPDATE users SET enable_email = NOT enable_email WHERE id = ?", [hmac, req.decoded.id]).then(function () { + return res.json({'msg': 'Email toggled'}); + }); +}); + secureRoutes.post('/changePayoutThreshold', function (req, res) { let threshold = req.body.threshold; if (threshold < global.config.payout.walletMin) { diff --git a/lib/worker.js b/lib/worker.js index 6547938..eba048d 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -210,7 +210,7 @@ function updateShareStats() { let address_parts = miner.split('_'); let address = address_parts[0]; let worker = address_parts[1]; - global.mysql.query("SELECT email FROM users WHERE username = ? limit 1", [address]).then(function (rows) { + global.mysql.query("SELECT email FROM users WHERE username = ? AND enable_email IS true limit 1", [address]).then(function (rows) { if (rows.length === 0) { return; }