diff --git a/src/config.ts b/src/config.ts index 0943736..92bbdc3 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 ec14179..83e3923 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/');