From 196ab43ea11136f9b71c9e118246843b060bf912 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sun, 12 Feb 2017 14:47:54 -0800 Subject: [PATCH 1/3] Updates to include the new e-mail settings stored in SQL. --- SQL_MIGRATIONS.md | 5 +++++ deployment/base.sql | 2 +- lib/worker.js | 12 +++++++++--- package.json | 1 + sql_sync/config_entries.json | 24 ++++++++++++++++++++++++ 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 SQL_MIGRATIONS.md diff --git a/SQL_MIGRATIONS.md b/SQL_MIGRATIONS.md new file mode 100644 index 0000000..ab1378f --- /dev/null +++ b/SQL_MIGRATIONS.md @@ -0,0 +1,5 @@ +2/12/2017 +--------- +```sql +ALTER TABLE monero_live.config MODIFY item_value TEXT; +``` \ No newline at end of file diff --git a/deployment/base.sql b/deployment/base.sql index 8b912eb..8bb5132 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -42,7 +42,7 @@ CREATE TABLE config id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT, module VARCHAR(32), item VARCHAR(32), - item_value VARCHAR(128), + item_value TEXT, item_type VARCHAR(64), Item_desc VARCHAR(512) ); diff --git a/lib/worker.js b/lib/worker.js index cc0268b..2ea5e05 100644 --- a/lib/worker.js +++ b/lib/worker.js @@ -1,6 +1,7 @@ "use strict"; const debug = require("debug")("worker"); const async = require("async"); +const sprintf = require("sprintf-js").sprintf; let threadName = "Worker Server "; let cycleCount = 0; @@ -214,9 +215,14 @@ function updateShareStats() { return; } // toAddress, subject, body - global.support.sendEmail(rows[0].email, "Worker " + worker + " not hashing", - "Hello,\r\n\r\nYour worker: " + worker + " has stopped submitting hashes at: " + global.support.formatDate(Date.now()) + - " UTC\r\n\r\nThank you,\r\nXMRPool.net Administration Team"); + let emailData = { + worker: worker, + timestamp: global.support.formatDate(Date.now()), + poolEmailSig: global.config.general.emailSig + }; + global.support.sendEmail(rows[0].email, + sprintf(global.config.email.workerNotHashingSubject, emailData), + sprintf(global.config.email.workerNotHashingBody, emailData)); }); } minerStats.hash = 0; diff --git a/package.json b/package.json index badf469..e21ab4d 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "request": "^2.79.0", "request-json": "0.6.1", "shapeshift.io": "1.3.0", + "sprintf-js": "^1.0.3", "uuid": "3.0.1", "wallet-address-validator": "0.1.0" } diff --git a/sql_sync/config_entries.json b/sql_sync/config_entries.json index ee84eb3..b9da6c4 100644 --- a/sql_sync/config_entries.json +++ b/sql_sync/config_entries.json @@ -510,5 +510,29 @@ "item_value": "", "item_type": "string", "Item_desc": "Host that receives share information" + }, + { + "id": 70, + "module": "email", + "item": "workerNotHashingBody", + "item_value": "Hello,\n\nYour worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n\nThank you,\n%(poolEmailSig)", + "item_type": "string", + "Item_desc": "Email sent to the miner when their worker stops hashing" + }, + { + "id": 71, + "module": "email", + "item": "workerNotHashingSubject", + "item_value": "Worker %(worker)s stopped hashing", + "item_type": "string", + "Item_desc": "Subject of email sent to miner when worker stops hashing" + }, + { + "id": 72, + "module": "general", + "item": "emailSig", + "item_value": "NodeJS-Pool Administration Team", + "item_type": "string", + "Item_desc": "Signature line for the emails." } ] \ No newline at end of file From 1101872f5cea5c557fd1510e7ea216fca3b834e2 Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sun, 12 Feb 2017 15:09:04 -0800 Subject: [PATCH 2/3] Missed an identifier. --- sql_sync/config_entries.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql_sync/config_entries.json b/sql_sync/config_entries.json index b9da6c4..56220ff 100644 --- a/sql_sync/config_entries.json +++ b/sql_sync/config_entries.json @@ -515,7 +515,7 @@ "id": 70, "module": "email", "item": "workerNotHashingBody", - "item_value": "Hello,\n\nYour worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n\nThank you,\n%(poolEmailSig)", + "item_value": "Hello,\n\nYour worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n\nThank you,\n%(poolEmailSig)s", "item_type": "string", "Item_desc": "Email sent to the miner when their worker stops hashing" }, From 8edd96535c4cea3b720186bca226ce2648b7055f Mon Sep 17 00:00:00 2001 From: Alexander Blair Date: Sun, 12 Feb 2017 17:24:46 -0800 Subject: [PATCH 3/3] Adding more base entries to SQL for the new worker emails. --- deployment/base.sql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deployment/base.sql b/deployment/base.sql index 8bb5132..9f31961 100644 --- a/deployment/base.sql +++ b/deployment/base.sql @@ -223,6 +223,9 @@ INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'rpcPasswordPath', '', 'string', 'Path and file for the RPC password file location'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('payout', 'maxPaymentTxns', '5', 'int', 'Maximum number of transactions in a single payment'); INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'shareHost', '', 'string', 'Host that receives share information'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingBody', 'Hello,\n\nYour worker: %(worker)s has stopped submitting hashes at: %(timestamp)s UTC\n\nThank you,\n%(poolEmailSig)s', 'string', 'Email sent to the miner when their worker stops hashing'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('email', 'workerNotHashingSubject', 'Worker %(worker)s stopped hashing', 'string', 'Subject of email sent to miner when worker stops hashing'); +INSERT INTO pool.config (module, item, item_value, item_type, Item_desc) VALUES ('general', 'emailSig', 'NodeJS-Pool Administration Team', 'string', 'Signature line for the emails.'); INSERT INTO pool.users (username, pass, email, admin, payout_threshold) VALUES ('Administrator', null, 'Password123', 1, 0); INSERT INTO pool.port_config (poolPort, difficulty, portDesc, portType, hidden, `ssl`) VALUES (3333, 1000, 'Low-End Hardware (Up to 30-40 h/s)', 'pplns', 0, 0); INSERT INTO pool.port_config (poolPort, difficulty, portDesc, portType, hidden, `ssl`) VALUES (5555, 5000, 'Medium-Range Hardware (Up to 160 h/s)', 'pplns', 0, 0);