fixed insufficient funds handling for sendTip and gild

This commit is contained in:
Akinwale Ariwodola 2017-09-24 08:08:38 +01:00
parent 2ee15ffeda
commit 1aaa0c3ef2
2 changed files with 5 additions and 3 deletions

6
app.js
View file

@ -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);
});
}

View file

@ -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