mirror of
https://github.com/wassname/talk.git
synced 2026-08-16 11:29:31 +08:00
fixed first time user
This commit is contained in:
@@ -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,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user