diff --git a/plugins/talk-plugin-toxic-comments/client/translations.yml b/plugins/talk-plugin-toxic-comments/client/translations.yml index b1553a3d9..ebcc31903 100644 --- a/plugins/talk-plugin-toxic-comments/client/translations.yml +++ b/plugins/talk-plugin-toxic-comments/client/translations.yml @@ -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 diff --git a/plugins/talk-plugin-toxic-comments/index.js b/plugins/talk-plugin-toxic-comments/index.js index 232f45052..0802a6c11 100644 --- a/plugins/talk-plugin-toxic-comments/index.js +++ b/plugins/talk-plugin-toxic-comments/index.js @@ -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, }; diff --git a/plugins/talk-plugin-toxic-comments/server/errors.js b/plugins/talk-plugin-toxic-comments/server/errors.js index 57f6ef959..17a2d20c6 100644 --- a/plugins/talk-plugin-toxic-comments/server/errors.js +++ b/plugins/talk-plugin-toxic-comments/server/errors.js @@ -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, }; diff --git a/plugins/talk-plugin-toxic-comments/server/hooks.js b/plugins/talk-plugin-toxic-comments/server/hooks.js index 07166c73a..991c243a0 100644 --- a/plugins/talk-plugin-toxic-comments/server/hooks.js +++ b/plugins/talk-plugin-toxic-comments/server/hooks.js @@ -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) { diff --git a/plugins/talk-plugin-toxic-comments/server/router.js b/plugins/talk-plugin-toxic-comments/server/router.js deleted file mode 100644 index 42f189d26..000000000 --- a/plugins/talk-plugin-toxic-comments/server/router.js +++ /dev/null @@ -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); - } - }); - -};