fixed first time user

This commit is contained in:
Wyatt Johnson
2018-05-24 10:11:49 -06:00
parent f3d89e63d2
commit 0c1e4873f8
2 changed files with 31 additions and 31 deletions
+20 -22
View File
@@ -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,
},
],
};
}
},
],
};
}
};
+11 -9
View File
@@ -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;
});
});
});