From 1260f1329360f091844621a40d287e4df5efffe1 Mon Sep 17 00:00:00 2001 From: Bruce Berrios <58147810+Bruception@users.noreply.github.com> Date: Tue, 7 Jun 2022 17:41:37 -0400 Subject: [PATCH 1/2] Add config for discord integration (#3081) Bruception --- backend/src/api/routes/users.ts | 14 +++++++++++++- backend/src/constants/base-configuration.ts | 13 +++++++++++++ backend/src/types/types.d.ts | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/src/api/routes/users.ts b/backend/src/api/routes/users.ts index 99b13b964..3480f039f 100644 --- a/backend/src/api/routes/users.ts +++ b/backend/src/api/routes/users.ts @@ -2,7 +2,11 @@ import joi from "joi"; import { authenticateRequest } from "../../middlewares/auth"; import { Router } from "express"; import * as UserController from "../controllers/user"; -import { asyncHandler, validateRequest } from "../../middlewares/api-utils"; +import { + asyncHandler, + validateRequest, + validateConfiguration, +} from "../../middlewares/api-utils"; import * as RateLimit from "../../middlewares/rate-limit"; import apeRateLimit from "../../middlewares/ape-rate-limit"; import { isUsernameValid } from "../../utils/validation"; @@ -268,9 +272,17 @@ router.patch( asyncHandler(UserController.editCustomTheme) ); +const requireDiscordIntegrationEnabled = validateConfiguration({ + criteria: (configuration) => { + return configuration.discordIntegration.enabled; + }, + invalidMessage: "Discord integration is not available at this time", +}); + router.post( "/discord/link", RateLimit.userDiscordLink, + requireDiscordIntegrationEnabled, authenticateRequest(), validateRequest({ body: { diff --git a/backend/src/constants/base-configuration.ts b/backend/src/constants/base-configuration.ts index 5a13df3a3..8fc3533ce 100644 --- a/backend/src/constants/base-configuration.ts +++ b/backend/src/constants/base-configuration.ts @@ -39,6 +39,9 @@ export const BASE_CONFIGURATION: MonkeyTypes.Configuration = { dailyLeaderboardCacheSize: 1, topResultsToAnnounce: 1, // This should never be 0. Setting to zero will announce all results. }, + discordIntegration: { + enabled: false, + }, }; export const CONFIGURATION_FORM_SCHEMA = { @@ -49,6 +52,16 @@ export const CONFIGURATION_FORM_SCHEMA = { type: "boolean", label: "In Maintenance", }, + discordIntegration: { + type: "object", + label: "Discord Integration", + fields: { + enabled: { + type: "boolean", + label: "Enabled", + }, + }, + }, results: { type: "object", label: "Results", diff --git a/backend/src/types/types.d.ts b/backend/src/types/types.d.ts index 8ca10c872..43f5a2d2c 100644 --- a/backend/src/types/types.d.ts +++ b/backend/src/types/types.d.ts @@ -44,6 +44,9 @@ declare namespace MonkeyTypes { dailyLeaderboardCacheSize: number; topResultsToAnnounce: number; }; + discordIntegration: { + enabled: boolean; + }; } interface DecodedToken { From 270fa5dfbe6a8e74db044481ef271d936c494d43 Mon Sep 17 00:00:00 2001 From: Bruce Berrios <58147810+Bruception@users.noreply.github.com> Date: Tue, 7 Jun 2022 17:56:20 -0400 Subject: [PATCH 2/2] Fix lines stylinh (#3082) --- backend/private/style.css | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/backend/private/style.css b/backend/private/style.css index e28298aec..8e3eb69a5 100644 --- a/backend/private/style.css +++ b/backend/private/style.css @@ -2,8 +2,6 @@ :root { --roundness: 0.5rem; - /* --sub-color: #e1e1e1; */ - /* --highlight-color: #0085a8; */ --bg-color: #323437; --main-color: #e2b714; --caret-color: #e2b714; @@ -134,8 +132,7 @@ input[type="checkbox"] { padding-left: 3rem; padding-top: 0.25rem; padding-bottom: 0.25rem; - border-left: var(--sub-color) 0.5px solid; - /* border-bottom: var(--sub-color) 0.5px dotted; */ + border-left: #64666955 0.5px solid; background: #fff; }