Let custom policy be configured with DITTO_POLICY

This commit is contained in:
Alex Gleason 2024-05-15 18:49:08 -05:00
parent 132eed36b4
commit 8e68d13ff1
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -60,7 +60,7 @@ async function policyFilter(event: NostrEvent): Promise<void> {
];
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/');