Let custom policy be configured with DITTO_POLICY
This commit is contained in:
parent
132eed36b4
commit
8e68d13ff1
|
@ -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
|
||||
|
|
|
@ -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/');
|
||||
|
|
Loading…
Reference in New Issue