diff --git a/src/config.ts b/src/config.ts index 92bbdc3..589386f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -219,7 +219,7 @@ 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:. */ + /** Path to the custom policy module. Must be an absolute path, https:, npm:, or jsr: URI. */ static get policy(): string { return Deno.env.get('DITTO_POLICY') || new URL('../data/policy.ts', import.meta.url).toString(); } diff --git a/src/pipeline.ts b/src/pipeline.ts index 83e3923..6162530 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -2,6 +2,7 @@ import { NKinds, NostrEvent, NPolicy, NSchema as n } from '@nostrify/nostrify'; import { LNURL } from '@nostrify/nostrify/ln'; import { PipePolicy } from '@nostrify/nostrify/policies'; import Debug from '@soapbox/stickynotes/debug'; +import { Stickynotes } from '@soapbox/stickynotes'; import { sql } from 'kysely'; import { Conf } from '@/config.ts'; @@ -55,6 +56,8 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise { + const console = new Stickynotes('ditto:policy'); + const policies: NPolicy[] = [ new MuteListPolicy(Conf.pubkey, await Storages.admin()), ]; @@ -62,14 +65,16 @@ async function policyFilter(event: NostrEvent): Promise { try { const CustomPolicy = (await import(Conf.policy)).default; policies.push(new CustomPolicy()); - } catch (_e) { - debug('policy not found - https://docs.soapbox.pub/ditto/policies/'); + console.info(`Using custom policy: ${Conf.policy}`); + } catch { + console.info('Custom policy not found '); } const policy = new PipePolicy(policies.reverse()); const result = await policy.call(event); - debug(JSON.stringify(result)); + console.debug(JSON.stringify(result)); + RelayError.assert(result); }