From 8e68d13ff15ac5744a341a2d022ef8383085d0eb Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 15 May 2024 18:49:08 -0500 Subject: [PATCH] Let custom policy be configured with DITTO_POLICY --- src/config.ts | 4 ++++ src/pipeline.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 09437361..92bbdc3e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -219,6 +219,10 @@ class Conf { static get firehoseEnabled(): boolean { return optionalBooleanSchema.parse(Deno.env.get('FIREHOSE_ENABLED')) ?? true; } + /** Path to the custom policy module. Supports any value Deno's `import()` accepts, including relative path, absolute path, https:, npm:, and jsr:. */ + static get policy(): string { + return Deno.env.get('DITTO_POLICY') || new URL('../data/policy.ts', import.meta.url).toString(); + } } const optionalBooleanSchema = z diff --git a/src/pipeline.ts b/src/pipeline.ts index ec14179f..83e39239 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -60,7 +60,7 @@ async function policyFilter(event: NostrEvent): Promise { ]; try { - const CustomPolicy = (await import('../data/policy.ts')).default; + const CustomPolicy = (await import(Conf.policy)).default; policies.push(new CustomPolicy()); } catch (_e) { debug('policy not found - https://docs.soapbox.pub/ditto/policies/');