From 30b3e91fdb8d7cb88e35649a9f17f7f35a4aa276 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 27 Jul 2017 15:34:04 +1000 Subject: [PATCH] documented more env vars --- config.js | 5 ++++- docs/_docs/02-01-configuration.md | 32 +++++++++++++++++++++++++++++++ services/karma.js | 25 +++++++++++++----------- 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/config.js b/config.js index 83cb5089f..3769998ae 100644 --- a/config.js +++ b/config.js @@ -102,7 +102,10 @@ const CONFIG = { // DISABLE_AUTOFLAG_SUSPECT_WORDS is true when the suspect words that are // matched should not be flagged. - DISABLE_AUTOFLAG_SUSPECT_WORDS: process.env.TALK_DISABLE_AUTOFLAG_SUSPECT_WORDS === 'TRUE' + DISABLE_AUTOFLAG_SUSPECT_WORDS: process.env.TALK_DISABLE_AUTOFLAG_SUSPECT_WORDS === 'TRUE', + + // TRUST_THRESHOLDS defines the thresholds used for automoderation. + TRUST_THRESHOLDS: process.env.TRUST_THRESHOLDS || 'comment:-1,-1;flag:-1,-1' }; //============================================================================== diff --git a/docs/_docs/02-01-configuration.md b/docs/_docs/02-01-configuration.md index f8bb762fc..cb9a51d23 100644 --- a/docs/_docs/02-01-configuration.md +++ b/docs/_docs/02-01-configuration.md @@ -37,6 +37,15 @@ environment variables. Refer to the [config.js](https://github.com/coralproject/talk/blob/master/config.js) file to see how the configuration is parsed. +### Webpack + +These are only used during the webpack build. + +- `TALK_THREADING_LEVEL` (_optional_) - specify the maximum depth of the comment + thread. (Default `3`) +- `TALK_DEFAULT_STREAM_TAB` (_optional_) - specify the default stream tab in the + admin. (Default `all`) + ### Database - `TALK_MONGO_URL` (*required*) - the database connection string for the MongoDB database. @@ -91,6 +100,29 @@ on the contents of those variables.** - `TALK_RECAPTCHA_SECRET` (*required for reCAPTCHA support*) - server secret used for enabling reCAPTCHA powered logins. If not provided it will instead default to providing only a time based lockout. - `TALK_RECAPTCHA_PUBLIC` (*required for reCAPTCHA support*) - client secret used for enabling reCAPTCHA powered logins. If not provided it will instead default to providing only a time based lockout. +### Trust + +Trust can automoderate comments based on user history. By specifying this +option, the beheviour can be changed to offer different results. + +- `TRUST_THRESHOLDS` (_optional_) - configure the reliability thresholds for + flagging and commenting. (Default `comment:-1,-1;flag:-1,-1`) + +The form of the environment variable: + +``` +:,;:,;... +``` + +The default could be read as: + +- When a commenter has one comment rejected, their next comment must be + premoderated once in order to post freely again. If they instead get rejected + again, then they must have two of their comments approved in order to get + added back to the queue. +- At the moment of writing, beheviour is not attached to the flagging + reliability, but it is recorded. + ### Plugins - `TALK_PLUGINS_JSON` (_optional_) - used to specify the plugin config via the diff --git a/services/karma.js b/services/karma.js index c76bcebb3..a2c087eaa 100644 --- a/services/karma.js +++ b/services/karma.js @@ -1,22 +1,25 @@ const debug = require('debug')('talk:services:karma'); const UserModel = require('../models/user'); +const { + TRUST_THRESHOLDS +} = require('../config'); /** * This will create an object with the property name of the action type as the * key and an object as it's value. This will contain a RELIABLE, and UNRELIABLE * property with the number of karma points associated with their particular * state. - * + * * If only the RELIABLE variable is provided, then it will also be used as the * UNRELIABLE variable. - * + * * The form of the environment variable is: - * + * * :,;:,;... - * + * * The default used is: - * - * comment:1,1;flag:-1,-1 + * + * comment:-1,-1;flag:-1,-1 */ const parseThresholds = (thresholds) => thresholds .split(';') @@ -50,16 +53,16 @@ const parseThresholds = (thresholds) => thresholds return acc; }, { comment: { - RELIABLE: -1, - UNRELIABLE: -1 + RELIABLE: 0, + UNRELIABLE: 0 }, flag: { - RELIABLE: -1, - UNRELIABLE: -1 + RELIABLE: 0, + UNRELIABLE: 0 } }); -const THRESHOLDS = parseThresholds(process.env.TRUST_THRESHOLDS || ''); +const THRESHOLDS = parseThresholds(TRUST_THRESHOLDS); debug('using thresholds: ', THRESHOLDS);