[next] Moderate (#2118)

* fix: load .env before building / watching

* feat: Implement AppBar, Brand, and SubBar

* feat: add card ui component

* feat: add modqueue components

* feat: implement modqueue

* feat: add translations

* test: add unit tests

* feat: single comment view

* test: feature / integration tests for modqueue

* test: fix remaining tests

* feature: support TextMatchOptions

* fix: remove body count marker

* fix: remove accidently added package

* feat: testHelper toJSON

* chore: cleanup + comments

* chore: better types

* test: fix test

* chore: refactor decision history test

* chore: tiny fix

* fix: adjust to recent server changes

* fix: marking suspect and banned words

* feat: added moderation queue edge to accept/reject comment payloads

- Simplified moderationQueue returns
- Simplified resolvers

* feat: update counts

* feat: added id's to moderation queue and settings

* fix+test: test count changes, apply fix

* chore: adapt to server change, and remove custom mutation handlers

* fix: use common utils

* fix: purify fix, babel fix

* fix: workaround css treeshake issue and upgrade css plugins

* fix: fixed snapshot

* fix: support empty word lists

* feat: separate client config
This commit is contained in:
Kiwi
2018-12-18 18:00:39 +00:00
committed by Wyatt Johnson
parent 90e67ca479
commit 1fc49f8e50
316 changed files with 11587 additions and 3005 deletions
-137
View File
@@ -1,137 +0,0 @@
import convict from "convict";
import Joi from "joi";
// Add custom format for the mongo uri scheme.
convict.addFormat({
name: "mongo-uri",
validate: (url: string) => {
Joi.assert(
url,
Joi.string().uri({
scheme: ["mongodb"],
})
);
},
});
// Add custom format for the redis uri scheme.
convict.addFormat({
name: "redis-uri",
validate: (url: string) => {
Joi.assert(
url,
Joi.string().uri({
scheme: ["redis"],
})
);
},
});
// Add a custom format for the optional-url.
convict.addFormat({
name: "optional-url",
validate: (url: string) => {
if (url) {
Joi.assert(url, Joi.string().uri());
}
},
// Ensure that there is no ending slash.
coerce: (url: string) => {
return url.replace(/\/$/, "");
},
});
const config = convict({
env: {
doc: "The application environment.",
format: ["production", "development", "test"],
default: "development",
env: "NODE_ENV",
},
enable_graphiql: {
doc: "When true, this will enable the GraphiQL routes",
format: Boolean,
default: false,
env: "ENABLE_GRAPHIQL",
arg: "enableGraphiQL",
},
port: {
doc: "The port to bind.",
format: "port",
default: 3000,
env: "PORT",
arg: "port",
},
mongodb: {
doc: "The MongoDB database to connect to.",
format: "mongo-uri",
default: "mongodb://127.0.0.1:27017/talk",
env: "MONGODB_URI",
arg: "mongodb",
sensitive: true,
},
redis: {
doc: "The Redis database to connect to.",
format: "redis-uri",
default: "redis://127.0.0.1:6379",
env: "REDIS_URI",
arg: "redis",
sensitive: true,
},
signing_secret: {
doc: "",
format: "*",
default: "keyboard cat", // TODO: (wyattjoh) evaluate best solution
env: "SIGNING_SECRET",
arg: "signingSecret",
sensitive: true,
},
signing_algorithm: {
doc: "",
format: [
"HS256",
"HS384",
"HS512",
"RS256",
"RS384",
"RS512",
"ES256",
"ES384",
"ES512",
],
default: "HS256",
env: "SIGNING_ALGORITHM",
arg: "signingAlgorithm",
},
logging_level: {
doc: "The logging level to print to the console",
format: ["fatal", "error", "warn", "info", "debug", "trace"],
default: "info",
env: "LOGGING_LEVEL",
arg: "logging",
},
static_uri: {
doc: "The URL that static assets will be hosted from",
format: "optional-url",
default: "",
env: "STATIC_URI",
arg: "staticUri",
},
disable_tenant_caching: {
doc:
"Disables the tenant caching, all tenants will be loaded from MongoDB each time it's needed",
format: Boolean,
default: false,
env: "DISABLE_TENANT_CACHING",
arg: "disableTenantCaching",
},
});
export type Config = typeof config;
export const createClientEnv = (c: Config) => ({
NODE_ENV: c.get("env"),
});
// Setup the base configuration.
export default config;
@@ -2,15 +2,15 @@
exports[`allows anchor links 1`] = `
Object {
"body": "<a href=\\"test\\" target=\\"_blank\\" rel=\\"noopener noreferrer\\">This is a link</a>",
"body": "<a href=\\"test\\" target=\\"_blank\\" rel=\\"noopener noreferrer\\">test</a>",
"linkCount": 1,
}
`;
exports[`allows anchor tags and counts them correctly 1`] = `
"<div>
<a href=\\"https://mozilla.org/\\" target=\\"_blank\\" rel=\\"noopener noreferrer\\">Mozilla</a>
<a href=\\"https://mozilla.org/\\" target=\\"_blank\\" rel=\\"noopener noreferrer\\">Mozilla</a>
<a href=\\"https://mozilla.org/\\" target=\\"_blank\\" rel=\\"noopener noreferrer\\">https://mozilla.org/</a>
<a href=\\"https://mozilla.org/\\" target=\\"_blank\\" rel=\\"noopener noreferrer\\">https://mozilla.org/</a>
</div>
"
`;
+6
View File
@@ -25,6 +25,12 @@ export function createPurify<T extends boolean = true>(
// Ensure we wrap all the links with the target + rel set.
node.setAttribute("target", "_blank");
node.setAttribute("rel", "noopener noreferrer");
// Ensure that all the links have the same link as they do text.
const href = node.getAttribute("href");
if (node.textContent !== href) {
node.textContent = href;
}
} else {
// The only tag that's allowed attributes is the "A" tag.
node.removeAttribute("href");