From 953138277e3e55372f07d12074924a2795bf5d1b Mon Sep 17 00:00:00 2001 From: OldHawk Date: Thu, 30 Nov 2017 17:50:20 +0800 Subject: [PATCH] fix(string): fixed translate string issues. --- modules/core/client/app/trans-string-en.js | 1 + modules/core/client/app/trans-string-zh.js | 1 + .../controllers/forums.server.controller.js | 8 ++-- .../invitations.server.controller.js | 42 +++++++++++-------- .../completes.server.controller.js | 2 +- .../controllers/torrents.server.controller.js | 4 +- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 5a076934..d2049543 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -1203,6 +1203,7 @@ ACTIVE_MAIL_RENDER_ERROR: 'The authentication mail render error', SENDING_ACTIVE_MAIL_FAILED: 'The authentication mail send failed', SCORE_NOT_ENOUGH: 'you don`t have enough score for this operation', + ALREADY_THUMBS_UP: 'you already thumbs up it', NO_ACCOUNT_WITH_THAT_USERNAME_OR_EMAIL: 'No account with that username or email has been found', USERNAME_EMAIL_NOT_BE_BLANK: 'Username or email field must not be blank', SENDING_RESET_MAIL_SUCCESSFULLY: 'An email has been sent to the provided email with further instructions. please check it then reset your password', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 93f4d62f..d8f49b33 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -1203,6 +1203,7 @@ ACTIVE_MAIL_RENDER_ERROR: '验证与激活邮件渲染失败', SENDING_ACTIVE_MAIL_FAILED: '验证与激活邮件发送失败', SCORE_NOT_ENOUGH: '您没有足够的积分进行此操作', + ALREADY_THUMBS_UP: '您已经赞过啦~', NO_ACCOUNT_WITH_THAT_USERNAME_OR_EMAIL: '没有您提供的邮箱或ID对应的用户帐户', USERNAME_EMAIL_NOT_BE_BLANK: '用户名或邮箱地址不为能空', SENDING_RESET_MAIL_SUCCESSFULLY: '系统已向您帐户的注册邮箱发送了一封验证邮件, 请检查邮件并跟据邮件提示进一步重置您的帐户密码', diff --git a/modules/forums/server/controllers/forums.server.controller.js b/modules/forums/server/controllers/forums.server.controller.js index daefb238..b3eadeb7 100644 --- a/modules/forums/server/controllers/forums.server.controller.js +++ b/modules/forums/server/controllers/forums.server.controller.js @@ -558,7 +558,7 @@ exports.thumbsUp = function (req, res) { }); if (exist) { return res.status(422).send({ - message: 'ALREADY_THUMBS_UP' + message: 'SERVER.ALREADY_THUMBS_UP' }); } else { if (req.user.score >= thumbsUpScore.topic) { @@ -569,7 +569,7 @@ exports.thumbsUp = function (req, res) { save(); } else { return res.status(422).send({ - message: 'SCORE_NOT_ENOUGH' + message: 'SERVER.SCORE_NOT_ENOUGH' }); } } @@ -585,7 +585,7 @@ exports.thumbsUp = function (req, res) { }); if (exist) { return res.status(422).send({ - message: 'ALREADY_THUMBS_UP' + message: 'SERVER.ALREADY_THUMBS_UP' }); } else { if (req.user.score >= thumbsUpScore.topic) { @@ -596,7 +596,7 @@ exports.thumbsUp = function (req, res) { save(); } else { return res.status(422).send({ - message: 'SCORE_NOT_ENOUGH' + message: 'SERVER.SCORE_NOT_ENOUGH' }); } } diff --git a/modules/invitations/server/controllers/invitations.server.controller.js b/modules/invitations/server/controllers/invitations.server.controller.js index c26f0e24..0a6ea545 100644 --- a/modules/invitations/server/controllers/invitations.server.controller.js +++ b/modules/invitations/server/controllers/invitations.server.controller.js @@ -46,26 +46,32 @@ exports.create = function (req, res) { } else { //res.json(invitation); var user = req.user; - user.update({ - $set: {score: user.score - config.meanTorrentConfig.invite.scoreExchange} - }).exec(function (err, result) { - if (err) { - return res.status(422).send({ - message: errorHandler.getErrorMessage(err) - }); - } else { - user.score = user.score - config.meanTorrentConfig.invite.scoreExchange; - res.json(user); - //create trace log - traceLogCreate(req, traceConfig.action.userInvitationExchange, { - user: req.user._id, - token: invitation.token, - score: config.meanTorrentConfig.invite.scoreExchange - }); - } - }); + if (user.score >= config.meanTorrentConfig.invite.scoreExchange) { + user.update({ + $set: {score: user.score - config.meanTorrentConfig.invite.scoreExchange} + }).exec(function (err, result) { + if (err) { + return res.status(422).send({ + message: errorHandler.getErrorMessage(err) + }); + } else { + user.score = user.score - config.meanTorrentConfig.invite.scoreExchange; + res.json(user); + //create trace log + traceLogCreate(req, traceConfig.action.userInvitationExchange, { + user: req.user._id, + token: invitation.token, + score: config.meanTorrentConfig.invite.scoreExchange + }); + } + }); + } else { + return res.status(422).send({ + message: 'SERVER.SCORE_NOT_ENOUGH' + }); + } } }); }; diff --git a/modules/torrents/server/controllers/completes.server.controller.js b/modules/torrents/server/controllers/completes.server.controller.js index 90cec51c..7acd4097 100644 --- a/modules/torrents/server/controllers/completes.server.controller.js +++ b/modules/torrents/server/controllers/completes.server.controller.js @@ -59,7 +59,7 @@ exports.removeWarning = function (req, res) { } else { if (req.user.score < hnrConfig.scoreToRemoveWarning) { return res.status(422).send({ - message: 'NO_ENOUGH_SCORE_TO_REMOVE_WARNING' + message: 'SERVER.SCORE_NOT_ENOUGH' }); } else { //update score diff --git a/modules/torrents/server/controllers/torrents.server.controller.js b/modules/torrents/server/controllers/torrents.server.controller.js index 16a1de14..0356edab 100644 --- a/modules/torrents/server/controllers/torrents.server.controller.js +++ b/modules/torrents/server/controllers/torrents.server.controller.js @@ -830,7 +830,7 @@ exports.thumbsUp = function (req, res) { }); if (exist) { return res.status(422).send({ - message: 'ALREADY_THUMBS_UP' + message: 'SERVER.ALREADY_THUMBS_UP' }); } else { if (req.user.score >= thumbsUpScore.torrent) { @@ -841,7 +841,7 @@ exports.thumbsUp = function (req, res) { save(); } else { return res.status(422).send({ - message: 'SCORE_NOT_ENOUGH' + message: 'SERVER.SCORE_NOT_ENOUGH' }); } }