From 0c1e4873f8f3a6e9655251361398434d089e7929 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 24 May 2018 10:09:44 -0600 Subject: [PATCH] fixed first time user --- services/moderation/phases/karma.js | 42 ++++++++++++++--------------- test/server/services/karma.js | 20 +++++++------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/services/moderation/phases/karma.js b/services/moderation/phases/karma.js index ad55b37a7..7a929824b 100644 --- a/services/moderation/phases/karma.js +++ b/services/moderation/phases/karma.js @@ -6,28 +6,26 @@ module.exports = ctx => { const { connectors: { services: { Karma } } } = ctx; const trust = get(ctx, 'user.metadata.trust', null); - if (trust !== null) { - // If the user is not a reliable commenter (passed the unreliability - // threshold by having too many rejected comments) then we can change the - // status of the comment to `SYSTEM_WITHHELD`, therefore pushing the user's - // comments away from the public eye until a moderator can manage them. This of - // course can only be applied if the comment's current status is `NONE`, - // we don't want to interfere if the comment was rejected. - if (Karma.isReliable('comment', trust) === false) { - // Add the flag related to Trust to the comment. - return { - status: 'SYSTEM_WITHHELD', - actions: [ - { - action_type: 'FLAG', - user_id: null, - group_id: 'TRUST', - metadata: { - trust, - }, + // If the user is not a reliable commenter (passed the unreliability + // threshold by having too many rejected comments) then we can change the + // status of the comment to `SYSTEM_WITHHELD`, therefore pushing the user's + // comments away from the public eye until a moderator can manage them. This of + // course can only be applied if the comment's current status is `NONE`, + // we don't want to interfere if the comment was rejected. + if (Karma.isReliable('comment', trust) === false) { + // Add the flag related to Trust to the comment. + return { + status: 'SYSTEM_WITHHELD', + actions: [ + { + action_type: 'FLAG', + user_id: null, + group_id: 'TRUST', + metadata: { + trust, }, - ], - }; - } + }, + ], + }; } }; diff --git a/test/server/services/karma.js b/test/server/services/karma.js index d725d8308..4a6753125 100644 --- a/test/server/services/karma.js +++ b/test/server/services/karma.js @@ -6,8 +6,8 @@ const Karma = require('../../../services/karma'); const thresholdsBackup = {}; const thresholdsOverride = { comment: { - RELIABLE: 1, - UNRELIABLE: -1, + RELIABLE: 2, + UNRELIABLE: 0, }, flag: { RELIABLE: 1, @@ -35,19 +35,21 @@ describe('services.Karma', () => { describe('#isReliable', () => { it('neutral', () => { - expect(Karma.isReliable('comment', {})).to.be.null; - expect(Karma.isReliable('comment', { comment: {} })).to.be.null; - expect(Karma.isReliable('comment', { comment: { karma: 0 } })).to.be.null; + expect(Karma.isReliable('comment', { comment: { karma: 1 } })).to.be.null; + expect(Karma.isReliable('comment', { comment: { karma: 0 } })).to.not.be + .null; + expect(Karma.isReliable('comment', { comment: { karma: -1 } })).to.not.be + .null; }); it('unreliable', () => { - expect(Karma.isReliable('comment', { comment: { karma: -1 } })).to.be - .false; - expect(Karma.isReliable('comment', { comment: { karma: -2 } })).to.be + expect(Karma.isReliable('comment', {})).to.be.false; + expect(Karma.isReliable('comment', { comment: {} })).to.be.false; + expect(Karma.isReliable('comment', { comment: { karma: 0 } })).to.be .false; }); it('reliable', () => { - expect(Karma.isReliable('comment', { comment: { karma: 1 } })).to.be.true; expect(Karma.isReliable('comment', { comment: { karma: 2 } })).to.be.true; + expect(Karma.isReliable('comment', { comment: { karma: 3 } })).to.be.true; }); }); });