Remove unused code

This commit is contained in:
Chi Vinh Le
2017-09-06 22:14:58 +07:00
parent 6f82fd76f5
commit a6b517b3dd
5 changed files with 0 additions and 58 deletions
@@ -3,10 +3,4 @@ en:
COMMENT_IS_TOXIC: |
Are you sure? The language in this comment might violate our community guidelines.
You can edit the comment or submit it for moderator review.
talk-plugin-featured-comments:
featured: Featured
go_to_conversation: Go to conversation
es:
talk-plugin-featured-comments:
featured: Remarcado
go_to_conversation: Ir al comentario
@@ -1,10 +1,8 @@
const {readFileSync} = require('fs');
const path = require('path');
const router = require('./server/router');
const hooks = require('./server/hooks');
module.exports = {
typeDefs: readFileSync(path.join(__dirname, 'server/typeDefs.graphql'), 'utf8'),
router,
hooks,
};
@@ -1,15 +1,10 @@
const {APIError} = require('../../../errors');
const ErrNoComment = new APIError('Comment must be provided', {
status: 400,
});
const ErrToxic = new APIError('Comment is toxic', {
status: 400,
translation_key: 'COMMENT_IS_TOXIC',
});
module.exports = {
ErrNoComment,
ErrToxic,
};
@@ -1,19 +1,8 @@
const perspective = require('./perspective');
const {ADD_COMMENT_TAG} = require('../../../perms/constants');
const {ErrToxic} = require('./errors');
const {TOXICITY_THRESHOLD} = require('./constants');
module.exports = {
Comment: {
tags: {
post(comment, input, {user}, _info, result) {
if (comment.metadata.perspective && user && user.can(ADD_COMMENT_TAG)) {
return result.concat({tag: {name: 'TOXIC', created_at: new Date()}});
}
return result;
}
},
},
RootMutation: {
createComment: {
async pre(_, {input}, _context, _info) {
@@ -1,34 +0,0 @@
const perspective = require('./perspective');
const {ErrNoComment} = require('./errors');
module.exports = (router) => {
/**
* POST /api/v1/toxicity/score
* args:
* - provide the comment in the request body
*/
router.post('/api/v1/toxicity/score', async (req, res, next) => {
const apiKey = process.env.TALK_PERSPECTIVE_API_KEY;
if(!apiKey) {
throw new Error('Please set the TALK_PERSPECTIVE_API_KEY environment variable to use the toxic-comments plugin. Visit https://www.perspectiveapi.com/ to request API access.');
}
const {comment} = req.body;
if(!comment) {
return next(ErrNoComment);
}
try {
const scores = await perspective.getScores(apiKey, comment);
return res.json({
comment,
score: scores.SEVERE_TOXICITY.summaryScore,
});
} catch(err) {
return next(err);
}
});
};