From bc1573cf47ff136c4fece5f47d483b4ffe49a986 Mon Sep 17 00:00:00 2001 From: BlueSkiesAndGreenPastures Date: Fri, 20 Jun 2025 12:24:59 -0500 Subject: [PATCH] safelink updates regarding feedback --- bskylink/src/bin.ts | 2 +- bskylink/src/config.ts | 10 +++++----- bskylink/src/routes/redirect.ts | 2 +- bskylink/tests/index.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bskylink/src/bin.ts b/bskylink/src/bin.ts index ee1301141c..8a4dfe03ed 100644 --- a/bskylink/src/bin.ts +++ b/bskylink/src/bin.ts @@ -13,7 +13,7 @@ async function main() { const link = await LinkService.create(cfg) - if (cfg.service.safelink === 1) { + if (cfg.service.safelinkEnabled) { cfg.eventCache.adaptiveFetchAndUpdate() } diff --git a/bskylink/src/config.ts b/bskylink/src/config.ts index 677484881f..f3cbd565b2 100644 --- a/bskylink/src/config.ts +++ b/bskylink/src/config.ts @@ -1,4 +1,4 @@ -import {envInt, envList, envStr} from '@atproto/common' +import {envBool, envInt, envList, envStr} from '@atproto/common' // import { type EventCache, eventCache } from '../cache/cache.js' import {EventCache} from './cache/cache.js' @@ -14,7 +14,7 @@ export type ServiceConfig = { version?: string hostnames: string[] appHostname: string - safelink: number + safelinkEnabled: boolean ozoneUrl?: string ozoneAgentHandle?: string ozoneAgentPass?: string @@ -44,7 +44,7 @@ export type Environment = { dbPostgresPoolSize?: number dbPostgresPoolMaxUses?: number dbPostgresPoolIdleTimeoutMs?: number - safelink?: number + safelinkEnabled?: boolean ozoneUrl?: string ozoneAgentHandle?: string ozoneAgentPass?: string @@ -64,7 +64,7 @@ export const readEnv = (): Environment => { dbPostgresPoolIdleTimeoutMs: envInt( 'LINK_DB_POSTGRES_POOL_IDLE_TIMEOUT_MS', ), - safelink: envInt('SAFELINK'), + safelinkEnabled: envBool('SAFELINK_ENABLED'), ozoneUrl: envStr('OZONE_URL'), ozoneAgentHandle: envStr('OZONE_AGENT_HANDLE'), ozoneAgentPass: envStr('OZONE_AGENT_PASS'), @@ -77,7 +77,7 @@ export const envToCfg = (env: Environment): Config => { version: env.version, hostnames: env.hostnames, appHostname: env.appHostname || 'bsky.app', - safelink: env.safelink || 0, + safelinkEnabled: env.safelinkEnabled || false, ozoneUrl: env.ozoneUrl || undefined, ozoneAgentHandle: env.ozoneAgentHandle || undefined, ozoneAgentPass: env.ozoneAgentPass || undefined, diff --git a/bskylink/src/routes/redirect.ts b/bskylink/src/routes/redirect.ts index b38619a8cb..61ef20cc54 100644 --- a/bskylink/src/routes/redirect.ts +++ b/bskylink/src/routes/redirect.ts @@ -45,7 +45,7 @@ export default function (ctx: AppContext, app: Express) { res.type('html') res.status(302) - if (ctx.cfg.service.safelink) { + if (ctx.cfg.service.safelinkEnabled) { const rulePresent: ToolsOzoneSafelinkDefs.Event | undefined = ctx.cfg.eventCache.smartGet(link) diff --git a/bskylink/tests/index.ts b/bskylink/tests/index.ts index cb2305edcf..7702301910 100644 --- a/bskylink/tests/index.ts +++ b/bskylink/tests/index.ts @@ -17,7 +17,7 @@ describe('link service', async () => { appHostname: 'test.bsky.app', dbPostgresSchema: 'link_test', dbPostgresUrl: process.env.DB_POSTGRES_URL, - safelink: 1, + safelinkEnabled: true, ozoneUrl: 'http://localhost:2583', ozoneAgentHandle: 'mod-authority.test', ozoneAgentPass: 'hunter2',