From f18c3d55fcaf54091d1669f77a4acddd367cdea9 Mon Sep 17 00:00:00 2001 From: OldHawk Date: Tue, 19 Jun 2018 12:04:51 +0800 Subject: [PATCH] feat(users): not to be idle if user have 'roam' medal --- config/env/torrents.js | 8 +++++--- config/lib/cron-job.js | 20 ++++++++++--------- .../controllers/systems.server.controller.js | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/config/env/torrents.js b/config/env/torrents.js index 5e9e53d4..0daf802f 100644 --- a/config/env/torrents.js +++ b/config/env/torrents.js @@ -480,6 +480,7 @@ module.exports = { * @activeMoreScorePerDay: idle more than one day need extra score * @activeMoreScorePerLevel: idle each level need extra score * @notIdleSafeLevel: safe lavel, more than this level account not to be idle status + * @unIdleMedalName: if user has these medal, the account do not to be idle status, value must be a Array */ sign: { openSignup: true, @@ -498,7 +499,8 @@ module.exports = { activeIdleAccountBasicScore: 50000, activeMoreScorePerDay: 100, activeMoreScorePerLevel: 1000, - notIdleSafeLevel: 30 + notIdleSafeLevel: 30, + unIdleMedalName: ['roam'] } }, @@ -1394,7 +1396,7 @@ module.exports = { * @noticeMsg: notice translate string show at top of home * @noticeShowAt: notice begin time to show * @timeFormats: time string format - * @exceptExaminationMedalName: except examination user must have medal name of 'noExamination' + * @exceptExaminationMedalName: except examination user must have medal name of 'noExamination', value must is a Array * @detailUrl: detail info of examination, maybe a forum link url * ------------------------------------------------------------------------------ * !IMPORTANT NOTE: @@ -1417,7 +1419,7 @@ module.exports = { noticeShowAt: '2018-01-28 00:00:00', timeFormats: 'YYYY-MM-DD HH:mm:ss' }, - exceptExaminationMedalName: 'noExamination', + exceptExaminationMedalName: ['noExamination'], detailUrl: '/forums/595c4491d5706705f67d93cf/59684780f928f42a9c79c613' }, diff --git a/config/lib/cron-job.js b/config/lib/cron-job.js index 9d15120e..c07edb5b 100644 --- a/config/lib/cron-job.js +++ b/config/lib/cron-job.js @@ -322,19 +322,21 @@ function checkUserAccountIdleStatus() { User.find({ status: 'normal', + isVip: false, + isOper: false, + isAdmin: false, last_signed: {$lt: Date.now() - signConfig.idle.accountIdleForTime}, - score: {$lt: safeScore} + score: {$lt: safeScore}, + medal: {$nin: signConfig.idle.unIdleMedalName} }).exec(function (err, users) { if (users) { users.forEach(function (u) { - if (!u.isOper && !u.isVip) { - u.update({ - $set: { - status: 'idle', - last_idled: u.last_signed - } - }).exec(); - } + u.update({ + $set: { + status: 'idle', + last_idled: u.last_signed + } + }).exec(); }); mtDebug.debugGreen('checkUserAccountIdleStatus: ' + users.length + ' users!'); } diff --git a/modules/systems/server/controllers/systems.server.controller.js b/modules/systems/server/controllers/systems.server.controller.js index 2f2a9e07..444a3b10 100644 --- a/modules/systems/server/controllers/systems.server.controller.js +++ b/modules/systems/server/controllers/systems.server.controller.js @@ -209,7 +209,7 @@ exports.initExaminationData = function (req, res) { isVip: false, isOper: false, isAdmin: false, - medals: {$nin: [examinationConfig.exceptExaminationMedalName]} + medals: {$nin: examinationConfig.exceptExaminationMedalName} }, {examinationData: exami}, {multi: true}, function (err, num) { if (err) { return res.status(422).send({