This commit is contained in:
Miodec 2022-06-08 02:02:20 +02:00
commit 48e1c0febb
4 changed files with 30 additions and 5 deletions

View file

@ -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;
}

View file

@ -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: {

View file

@ -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",

View file

@ -44,6 +44,9 @@ declare namespace MonkeyTypes {
dailyLeaderboardCacheSize: number;
topResultsToAnnounce: number;
};
discordIntegration: {
enabled: boolean;
};
}
interface DecodedToken {