From 3b6f3c9ea89de0ded46af09f78518145abe1d352 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Mon, 22 Oct 2018 15:52:17 -0600 Subject: [PATCH] fix: rename wordlist to wordList --- .../app/middleware/passport/strategies/oidc.ts | 3 --- src/core/server/graph/tenant/schema/schema.graphql | 14 +++++++------- src/core/server/models/settings.ts | 6 +++--- src/core/server/models/tenant.ts | 2 +- src/core/server/services/comments/index.ts | 1 - .../services/comments/moderation/phases/index.ts | 10 +++++----- .../phases/{premod.ts => preModerate.ts} | 2 +- .../comments/moderation/phases/wordlist.ts | 10 +++++----- 8 files changed, 22 insertions(+), 26 deletions(-) rename src/core/server/services/comments/moderation/phases/{premod.ts => preModerate.ts} (94%) diff --git a/src/core/server/app/middleware/passport/strategies/oidc.ts b/src/core/server/app/middleware/passport/strategies/oidc.ts index b810a18f9..f4d07a108 100644 --- a/src/core/server/app/middleware/passport/strategies/oidc.ts +++ b/src/core/server/app/middleware/passport/strategies/oidc.ts @@ -209,9 +209,6 @@ export default class OIDCStrategy extends Strategy { this.mongo = mongo; this.cache = new TenantCacheAdapter(tenantCache); - - // Connect the cache adapter. - this.cache.subscribe(); } private lookupJWKSClient( diff --git a/src/core/server/graph/tenant/schema/schema.graphql b/src/core/server/graph/tenant/schema/schema.graphql index 4bd6d0e2f..268e303c4 100644 --- a/src/core/server/graph/tenant/schema/schema.graphql +++ b/src/core/server/graph/tenant/schema/schema.graphql @@ -226,9 +226,9 @@ enum MODERATION_MODE { } """ -Wordlist describes all the available wordlists. +WordList describes all the available wordLists. """ -type Wordlist { +type WordList { """ banned words will by default reject the comment if it is found. """ @@ -704,9 +704,9 @@ type Settings { email: Email! @auth(roles: [ADMIN]) """ - wordlist will return a given list of words. + wordList will return a given list of words. """ - wordlist: Wordlist! @auth(roles: [ADMIN, MODERATOR]) + wordList: WordList! @auth(roles: [ADMIN, MODERATOR]) """ auth contains all the settings related to authentication and authorization. @@ -1304,7 +1304,7 @@ input SettingsEmailInput { fromAddress: String } -input SettingsWordlistInput { +input SettingsWordListInput { """ banned words will by default reject the comment if it is found. """ @@ -1641,9 +1641,9 @@ input SettingsInput { organizationContactEmail: String """ - wordlist will return a given list of words. + wordList will return a given list of words. """ - wordlist: SettingsWordlistInput + wordList: SettingsWordListInput """ email is the set of credentials and settings associated with the organization. diff --git a/src/core/server/models/settings.ts b/src/core/server/models/settings.ts index 6434f30c8..4091b8f37 100644 --- a/src/core/server/models/settings.ts +++ b/src/core/server/models/settings.ts @@ -6,7 +6,7 @@ import { GQLKarma, GQLMODERATION_MODE, GQLReactionConfiguration, - GQLWordlist, + GQLWordList, } from "talk-server/graph/tenant/schema/__generated__/types"; // export interface EmailDomainRuleCondition { @@ -89,9 +89,9 @@ export interface Settings extends ModerationSettings { karma: GQLKarma; /** - * wordlist stores all the banned/suspect words. + * wordList stores all the banned/suspect words. */ - wordlist: GQLWordlist; + wordList: GQLWordList; /** * Set of configured authentication integrations. diff --git a/src/core/server/models/tenant.ts b/src/core/server/models/tenant.ts index 166dcc9c2..aa66d8229 100644 --- a/src/core/server/models/tenant.ts +++ b/src/core/server/models/tenant.ts @@ -75,7 +75,7 @@ export async function createTenant(mongo: Db, input: CreateTenantInput) { charCount: { enabled: false, }, - wordlist: { + wordList: { suspect: [], banned: [], }, diff --git a/src/core/server/services/comments/index.ts b/src/core/server/services/comments/index.ts index 82e10c97c..3de8b8ee5 100644 --- a/src/core/server/services/comments/index.ts +++ b/src/core/server/services/comments/index.ts @@ -92,7 +92,6 @@ export async function create( // Insert and handle creating the actions. comment = await addCommentActions(mongo, tenant, comment, inputs); - // asse } if (input.parent_id) { diff --git a/src/core/server/services/comments/moderation/phases/index.ts b/src/core/server/services/comments/moderation/phases/index.ts index a0a724cc6..973e615c6 100644 --- a/src/core/server/services/comments/moderation/phases/index.ts +++ b/src/core/server/services/comments/moderation/phases/index.ts @@ -1,15 +1,15 @@ import { IntermediateModerationPhase } from "talk-server/services/comments/moderation"; -import { premod } from "talk-server/services/comments/moderation/phases/premod"; -import { toxic } from "talk-server/services/comments/moderation/phases/toxic"; import { assetClosed } from "./assetClosed"; import { commentingDisabled } from "./commentingDisabled"; import { commentLength } from "./commentLength"; import { karma } from "./karma"; import { links } from "./links"; +import { preModerate } from "./preModerate"; import { spam } from "./spam"; import { staff } from "./staff"; -import { wordlist } from "./wordlist"; +import { toxic } from "./toxic"; +import { wordList } from "./wordList"; /** * The moderation phases to apply for each comment being processed. @@ -18,11 +18,11 @@ export const moderationPhases: IntermediateModerationPhase[] = [ commentLength, assetClosed, commentingDisabled, - wordlist, + wordList, staff, links, karma, spam, toxic, - premod, + preModerate, ]; diff --git a/src/core/server/services/comments/moderation/phases/premod.ts b/src/core/server/services/comments/moderation/phases/preModerate.ts similarity index 94% rename from src/core/server/services/comments/moderation/phases/premod.ts rename to src/core/server/services/comments/moderation/phases/preModerate.ts index 7ccdcfb73..da1cd2420 100755 --- a/src/core/server/services/comments/moderation/phases/premod.ts +++ b/src/core/server/services/comments/moderation/phases/preModerate.ts @@ -13,7 +13,7 @@ const testModerationMode = (settings: Partial) => // This phase checks to see if the settings have premod enabled, if they do, // the comment is premod, otherwise, it's just none. -export const premod: IntermediateModerationPhase = ({ +export const preModerate: IntermediateModerationPhase = ({ asset, tenant, }): IntermediatePhaseResult | void => { diff --git a/src/core/server/services/comments/moderation/phases/wordlist.ts b/src/core/server/services/comments/moderation/phases/wordlist.ts index 05f6431b9..71f8eb860 100755 --- a/src/core/server/services/comments/moderation/phases/wordlist.ts +++ b/src/core/server/services/comments/moderation/phases/wordlist.ts @@ -9,8 +9,8 @@ import { } from "talk-server/services/comments/moderation"; import { containsMatchingPhrase } from "talk-server/services/comments/moderation/wordlist"; -// This phase checks the comment against the wordlist. -export const wordlist: IntermediateModerationPhase = ({ +// This phase checks the comment against the wordList. +export const wordList: IntermediateModerationPhase = ({ tenant, comment, }): IntermediatePhaseResult | void => { @@ -21,9 +21,9 @@ export const wordlist: IntermediateModerationPhase = ({ // Decide the status based on whether or not the current asset/settings // has pre-mod enabled or not. If the comment was rejected based on the - // wordlist, then reject it, otherwise if the moderation setting is + // wordList, then reject it, otherwise if the moderation setting is // premod, set it to `premod`. - if (containsMatchingPhrase(tenant.wordlist.banned, comment.body)) { + if (containsMatchingPhrase(tenant.wordList.banned, comment.body)) { // Add the flag related to Trust to the comment. return { status: GQLCOMMENT_STATUS.REJECTED, @@ -42,7 +42,7 @@ export const wordlist: IntermediateModerationPhase = ({ // If the wordlist has matched the suspect word filter and we haven't disabled // auto-flagging suspect words, then we should flag the comment! - if (containsMatchingPhrase(tenant.wordlist.suspect, comment.body)) { + if (containsMatchingPhrase(tenant.wordList.suspect, comment.body)) { return { actions: [ {