From 1aaa0c3ef2bc435367f75241890f6a0499b21889 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Sun, 24 Sep 2017 08:08:38 +0100 Subject: [PATCH] fixed insufficient funds handling for sendTip and gild --- app.js | 6 ++++-- sql/ddl.sql | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app.js b/app.js index 3f6930c..bc43078 100644 --- a/app.js +++ b/app.js @@ -222,7 +222,8 @@ const sendTip = (sender, recipient, amount, tipdata, callback) => { // balance is less than amount to tip, or the difference after sending the tip is negative if (senderBalance < amount || (senderBalance - amount) < 0) { return sendPMUsingTemplate('onsendtip.insufficientfunds', - { how_to_use_url: config.howToUseUrl, recipient: `u/${recipient}`, amount: amount, balance: senderBalance }, message.data.author, () => { + { how_to_use_url: config.howToUseUrl, recipient: `u/${recipient}`, amount: amount, balance: senderBalance }, + tipdata.message.data.author, () => { cb(new Error('Insufficient funds'), null); }); } @@ -513,7 +514,8 @@ const sendGild = (sender, recipient, amount, gilddata, callback) => { // balance is less than amount required for gilding, or the difference after sending the tip is negative if (senderBalance < amount || (senderBalance - amount) < 0) { return sendPMUsingTemplate('ongild.insufficientfunds', - { how_to_use_url: config.howToUseUrl, amount: amount, amount_usd: gilddata.amountUsd, balance: senderBalance }, message.data.author, () => { + { how_to_use_url: config.howToUseUrl, amount: amount, amount_usd: gilddata.amountUsd, balance: senderBalance }, + gilddata.message.data.author, () => { cb(new Error('Insufficient funds'), null); }); } diff --git a/sql/ddl.sql b/sql/ddl.sql index a994e25..b0e8787 100644 --- a/sql/ddl.sql +++ b/sql/ddl.sql @@ -25,7 +25,7 @@ CREATE TABLE Messages `Created` DATETIME NOT NULL, PRIMARY KEY `PK_MessageId` (`Id`), FOREIGN KEY `FK_MessageAuthor` (`AuthorId`) REFERENCES `Users` (`Id`), - UNIQUE KEY `Idx_MessageRedditId` (`RedditId`) + UNIQUE KEY `Idx_MessageFullId` (`RedditFullId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=4; CREATE TABLE Tips