[next] Perspective API Integration (#1797)

* feat: initial toxic comments impl

* feat: improved logging

* feat: tenant cache adapter

* feat: move more types into graphql
This commit is contained in:
Wyatt Johnson
2018-08-14 14:37:00 +00:00
committed by GitHub
parent d2106b3de5
commit 0b3aead1d2
33 changed files with 1088 additions and 417 deletions
@@ -1,7 +1,10 @@
import { GQLAuthIntegrationsTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
import { AuthIntegration, AuthIntegrations } from "talk-server/models/settings";
import {
AuthIntegrations,
EnableableIntegration,
} from "talk-server/models/settings";
const disabled: AuthIntegration = { enabled: false };
const disabled: EnableableIntegration = { enabled: false };
const AuthIntegrations: GQLAuthIntegrationsTypeResolver<AuthIntegrations> = {
local: auth => auth.local || disabled,
@@ -38,6 +38,16 @@ enum ACTION_ITEM_TYPE {
COMMENTS
}
enum ACTION_GROUP {
SPAM_COMMENT
TOXIC_COMMENT
BODY_COUNT
TRUST
LINKS
BANNED_WORD
SUSPECT_WORD
}
################################################################################
## Settings
################################################################################
@@ -57,9 +67,9 @@ enum MODERATION_MODE {
}
"""
WordlistSettings describes all the available wordlists.
Wordlist describes all the available wordlists.
"""
type WordlistSettings {
type Wordlist {
"""
banned words will by default reject the comment if it is found.
"""
@@ -177,6 +187,111 @@ type AuthSettings {
integrations: AuthIntegrations!
}
################################################################################
## ExternalIntegrations
################################################################################
type AkismetExternalIntegration {
"""
enabled when True will enable the integration.
"""
enabled: Boolean!
"""
The key for the Akismet integration.
"""
key: String
"""
The site (blog) for the Akismet integration.
"""
site: String
}
type PerspectiveExternalIntegration {
"""
enabled when True will enable the integration.
"""
enabled: Boolean!
"""
The endpoint that Talk should use to communicate with the perspective API.
"""
endpoint: String
"""
The key for the Perspective API integration.
"""
key: String
"""
The threshold that given a specific toxic comment score, the comment will
be marked by Talk as toxic.
"""
threshold: Float
"""
When True, comments sent will not be stored by the Google Perspective API.
"""
doNotStore: Boolean
}
type ExternalIntegrations {
"""
akismet provides integration with the Akismet Spam detection service.
"""
akismet: AkismetExternalIntegration!
"""
perspective provides integration with the Perspective API comment analysis
platform.
"""
perspective: PerspectiveExternalIntegration!
}
################################################################################
## Karma
################################################################################
"""
KarmaThreshold defines the bounds for which a User will become unreliable or
reliable based on their karma score. If the score is equal or less than the
unreliable value, they are unreliable. If the score is equal or more than the
reliable value, they are reliable. If they are neither reliable or unreliable
then they are neutral.
"""
type KarmaThreshold {
reliable: Int!
unreliable: Int!
}
type KarmaThresholds {
"""
flag represents karma settings in relation to how well a User's flagging
ability aligns with the moderation decicions made by moderators.
"""
flag: KarmaThreshold!
"""
comment represents the karma setting in relation to how well a User's comments are moderated.
"""
comment: KarmaThreshold!
}
type Karma {
"""
When true, checks will be completed to ensure that the Karma checks are
completed.
"""
enabled: Boolean!
"""
karmaThresholds contains the currently set thresholds for triggering Trust
beheviour.
"""
thresholds: KarmaThresholds!
}
################################################################################
## Settings
################################################################################
@@ -295,7 +410,7 @@ type Settings {
"""
wordlist will return a given list of words.
"""
wordlist: WordlistSettings @auth(roles: [ADMIN, MODERATOR])
wordlist: Wordlist @auth(roles: [ADMIN, MODERATOR])
"""
domains will return a given list of whitelisted domains.
@@ -306,6 +421,17 @@ type Settings {
auth contains all the settings related to authentication and authorization.
"""
auth: AuthSettings!
"""
integrations contains all the external integrations that can be enabled.
"""
integrations: ExternalIntegrations @auth(roles: [ADMIN])
"""
karma is the set of settings related to how user Trust and Karma are
handled.
"""
karma: Karma @auth(roles: [ADMIN, MODERATOR])
}
################################################################################
@@ -728,7 +854,7 @@ input SettingsInput {
charCount: Int
organizationName: String
organizationContactEmail: String
# wordlist: WordlistSettings @auth(roles: [ADMIN, MODERATOR])
# wordlist: Wordlist @auth(roles: [ADMIN, MODERATOR])
domains: [String!]
# auth: AuthSettings!
}