From 14869012a6db59636942e1939f54857fbfc61982 Mon Sep 17 00:00:00 2001 From: Daniel Haarhoff Date: Thu, 28 Nov 2024 14:54:58 +0000 Subject: [PATCH] Introduce a featureflag to limit sending of notifications to our sandbox Refs: #645 --- fly.sandbox.toml | 1 + src/Router.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fly.sandbox.toml b/fly.sandbox.toml index e5a6a10..963a79f 100644 --- a/fly.sandbox.toml +++ b/fly.sandbox.toml @@ -6,6 +6,7 @@ BULLMQ_WORKER_POLL = "30 seconds" SLACK_CHANNEL_ID = "C05N0JHBC1Y" SLACK_SHARE_CHANNEL_ID = "C05V6TXHETS" REDIS_IP_VERSION = "6" +CAN_NOTIFY_SCIETY = "true" [http_service] internal_port = 3000 diff --git a/src/Router.ts b/src/Router.ts index 5506854..55b93e2 100644 --- a/src/Router.ts +++ b/src/Router.ts @@ -1,6 +1,6 @@ import { HttpMiddleware, HttpRouter, HttpServerRequest, HttpServerResponse } from '@effect/platform' import { Schema, TreeFormatter } from '@effect/schema' -import { Array, Context, Data, Effect, Exit, Match, Option } from 'effect' +import { Array, Config, Context, Data, Effect, Exit, Match, Option } from 'effect' import { StatusCodes } from 'http-status-codes' import { createHash } from 'node:crypto' import slackifyMarkdown from 'slackify-markdown' @@ -222,6 +222,12 @@ const RequestsSchema = Schema.Array( }), ) -const notifyScietyCoarInbox = Effect.void +const notifyScietyCoarInbox = Effect.gen(function* () { + const canNotifySciety = yield* Config.withDefault(Config.boolean('CAN_NOTIFY_SCIETY'), false) + if (!canNotifySciety) { + return + } + yield* Effect.logDebug('Should notify Sciety') +}) const md5 = (content: string) => createHash('md5').update(content).digest('hex')