From f467f94fce05323b38aff009daf49a5da9c2b129 Mon Sep 17 00:00:00 2001 From: Rory& Date: Thu, 23 Oct 2025 14:16:09 +0200 Subject: [PATCH] Use EnvConfig for proto settings logging, unify setting --- src/api/routes/users/@me/settings-proto/1.ts | 5 ++--- src/api/routes/users/@me/settings-proto/2.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/api/routes/users/@me/settings-proto/1.ts b/src/api/routes/users/@me/settings-proto/1.ts index b0164bc42..9c81c43d1 100644 --- a/src/api/routes/users/@me/settings-proto/1.ts +++ b/src/api/routes/users/@me/settings-proto/1.ts @@ -21,7 +21,7 @@ import { PreloadedUserSettings } from "discord-protos"; import { JsonValue } from "@protobuf-ts/runtime"; import { route } from "@spacebar/api/middlewares"; import { UserSettingsProtos } from "@spacebar/database"; -import { emitEvent, OrmUtils } from "@spacebar/util"; +import { emitEvent, OrmUtils, EnvConfig } from "@spacebar/util"; import { SettingsProtoJsonResponse, SettingsProtoResponse, SettingsProtoUpdateJsonSchema, SettingsProtoUpdateSchema } from "@spacebar/schemas"; const router: Router = Router({ mergeParams: true }); @@ -142,8 +142,7 @@ async function patchUserSettings(userId: string, updatedSettings: PreloadedUserS }; } - if ((process.env.LOG_PROTO_UPDATES || process.env.LOG_PROTO_SETTINGS_UPDATES) && process.env.LOG_PROTO_SETTINGS_UPDATES !== "false") - console.log(`Updating user settings for user ${userId} with atomic=${atomic}:`, updatedSettings); + if (EnvConfig.logging.logProtoUpdates.includes("SETTINGS")) console.log(`Updating user settings for user ${userId} with atomic=${atomic}:`, updatedSettings); if (!atomic) { settings = PreloadedUserSettings.fromJson( diff --git a/src/api/routes/users/@me/settings-proto/2.ts b/src/api/routes/users/@me/settings-proto/2.ts index aa9a09468..f595f53b6 100644 --- a/src/api/routes/users/@me/settings-proto/2.ts +++ b/src/api/routes/users/@me/settings-proto/2.ts @@ -21,7 +21,7 @@ import { FrecencyUserSettings } from "discord-protos"; import { JsonValue } from "@protobuf-ts/runtime"; import { route } from "@spacebar/api/middlewares"; import { UserSettingsProtos } from "@spacebar/database"; -import { emitEvent, OrmUtils } from "@spacebar/util"; +import { emitEvent, OrmUtils, EnvConfig } from "@spacebar/util"; import { SettingsProtoJsonResponse, SettingsProtoResponse, SettingsProtoUpdateJsonSchema, SettingsProtoUpdateSchema } from "@spacebar/schemas"; const router: Router = Router({ mergeParams: true }); @@ -142,8 +142,7 @@ async function patchUserSettings(userId: string, updatedSettings: FrecencyUserSe }; } - if ((process.env.LOG_PROTO_UPDATES || process.env.LOG_PROTO_FRECENCY_UPDATES) && process.env.LOG_PROTO_FRECENCY_UPDATES !== "false") - console.log(`Updating frecency settings for user ${userId} with atomic=${atomic}:`, updatedSettings); + if (EnvConfig.logging.logProtoUpdates.includes("FRECENCY")) console.log(`Updating frecency settings for user ${userId} with atomic=${atomic}:`, updatedSettings); if (!atomic) { settings = FrecencyUserSettings.fromJson(