From 3fa2a954297df36d4c33186559c681d4967970b6 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Fri, 24 Mar 2023 21:53:59 -0400 Subject: oapi: policies --- src/util/config/types/subconfigurations/limits/RateLimits.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/util/config/types') diff --git a/src/util/config/types/subconfigurations/limits/RateLimits.ts b/src/util/config/types/subconfigurations/limits/RateLimits.ts index caba740b..0ce0827c 100644 --- a/src/util/config/types/subconfigurations/limits/RateLimits.ts +++ b/src/util/config/types/subconfigurations/limits/RateLimits.ts @@ -16,11 +16,11 @@ along with this program. If not, see . */ -import { RouteRateLimit, RateLimitOptions } from "."; +import { RateLimitOptions, RouteRateLimit } from "."; export class RateLimits { enabled: boolean = false; - ip: Omit = { + ip: RateLimitOptions = { count: 500, window: 5, }; -- cgit 1.4.1 From 942cce913dcf00acc94f4a2cefc0902427a6c7b7 Mon Sep 17 00:00:00 2001 From: Puyodead1 Date: Sat, 6 May 2023 23:45:09 -0400 Subject: add option to auto add bot users to new apps --- assets/openapi.json | 8 ++++++++ assets/schemas.json | 8 ++++++++ src/api/routes/applications/index.ts | 21 +++++++++++++++++++++ src/util/config/types/GeneralConfiguration.ts | 1 + 4 files changed, 38 insertions(+) (limited to 'src/util/config/types') diff --git a/assets/openapi.json b/assets/openapi.json index 2dc78741..14bfb70a 100644 --- a/assets/openapi.json +++ b/assets/openapi.json @@ -5994,6 +5994,9 @@ }, "suppress": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "required": [ @@ -7190,9 +7193,14 @@ }, "instanceId": { "type": "string" + }, + "autoCreateBotUsers": { + "type": "boolean", + "default": false } }, "required": [ + "autoCreateBotUsers", "correspondenceEmail", "correspondenceUserID", "frontPage", diff --git a/assets/schemas.json b/assets/schemas.json index dc25cacd..68ef8187 100644 --- a/assets/schemas.json +++ b/assets/schemas.json @@ -197032,6 +197032,9 @@ }, "suppress": { "type": "boolean" + }, + "flags": { + "type": "integer" } }, "additionalProperties": false, @@ -422581,10 +422584,15 @@ }, "instanceId": { "type": "string" + }, + "autoCreateBotUsers": { + "type": "boolean", + "default": false } }, "additionalProperties": false, "required": [ + "autoCreateBotUsers", "correspondenceEmail", "correspondenceUserID", "frontPage", diff --git a/src/api/routes/applications/index.ts b/src/api/routes/applications/index.ts index 1e536a06..27300c4a 100644 --- a/src/api/routes/applications/index.ts +++ b/src/api/routes/applications/index.ts @@ -20,6 +20,7 @@ import { route } from "@spacebar/api"; import { Application, ApplicationCreateSchema, + Config, User, trimSpecial, } from "@spacebar/util"; @@ -68,6 +69,26 @@ router.post( flags: 0, }); + // april 14, 2023: discord made bot users be automatically added to all new apps + const { autoCreateBotUsers } = Config.get().general; + if (autoCreateBotUsers) { + const user = await User.register({ + username: app.name, + password: undefined, + id: app.id, + req, + }); + + user.id = app.id; + user.premium_since = new Date(); + user.bot = true; + + await user.save(); + + // flags is NaN here? + app.assign({ bot: user, flags: app.flags || 0 }); + } + await app.save(); res.json(app); diff --git a/src/util/config/types/GeneralConfiguration.ts b/src/util/config/types/GeneralConfiguration.ts index c20fe9a7..cff8c527 100644 --- a/src/util/config/types/GeneralConfiguration.ts +++ b/src/util/config/types/GeneralConfiguration.ts @@ -28,4 +28,5 @@ export class GeneralConfiguration { correspondenceUserID: string | null = null; image: string | null = null; instanceId: string = Snowflake.generate(); + autoCreateBotUsers: boolean = false; } -- cgit 1.4.1 From 6f7ce2bc77d18b6932a1af39f46f3f1c0e902b94 Mon Sep 17 00:00:00 2001 From: Zert3x <81202811+Zert3x@users.noreply.github.com> Date: Sun, 28 May 2023 21:27:01 -0400 Subject: forwaded -> forwarded --- src/util/config/types/SecurityConfiguration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/util/config/types') diff --git a/src/util/config/types/SecurityConfiguration.ts b/src/util/config/types/SecurityConfiguration.ts index 5e971cfe..35776642 100644 --- a/src/util/config/types/SecurityConfiguration.ts +++ b/src/util/config/types/SecurityConfiguration.ts @@ -28,7 +28,7 @@ export class SecurityConfiguration { // header to get the real user ip address // X-Forwarded-For for nginx/reverse proxies // CF-Connecting-IP for cloudflare - forwadedFor: string | null = null; + forwardedFor: string | null = null; ipdataApiKey: string | null = "eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9"; mfaBackupCodeCount: number = 10; -- cgit 1.4.1