mirror of
https://github.com/aljazceru/ditto.git
synced 2026-01-31 02:54:21 +01:00
Expose the Ditto pubkey to the policy worker
This commit is contained in:
@@ -50,7 +50,7 @@ class PolicyWorker implements NPolicy {
|
||||
await this.worker.init({
|
||||
path: Conf.policy,
|
||||
databaseUrl: Conf.databaseUrl,
|
||||
adminPubkey: Conf.pubkey,
|
||||
pubkey: Conf.pubkey,
|
||||
});
|
||||
|
||||
console.warn(`Using custom policy: ${Conf.policy}`);
|
||||
|
||||
@@ -18,7 +18,7 @@ interface PolicyInit {
|
||||
/** Database URL to connect to. */
|
||||
databaseUrl: string;
|
||||
/** Admin pubkey to use for EventsDB checks. */
|
||||
adminPubkey: string;
|
||||
pubkey: string;
|
||||
}
|
||||
|
||||
export class CustomPolicy implements NPolicy {
|
||||
@@ -29,18 +29,18 @@ export class CustomPolicy implements NPolicy {
|
||||
return this.policy.call(event, signal);
|
||||
}
|
||||
|
||||
async init({ path, databaseUrl, adminPubkey }: PolicyInit): Promise<void> {
|
||||
async init({ path, databaseUrl, pubkey }: PolicyInit): Promise<void> {
|
||||
const Policy = (await import(path)).default;
|
||||
|
||||
const { kysely } = DittoDB.create(databaseUrl, { poolSize: 1 });
|
||||
|
||||
const store = new EventsDB({
|
||||
kysely,
|
||||
pubkey: adminPubkey,
|
||||
pubkey,
|
||||
timeout: 1_000,
|
||||
});
|
||||
|
||||
this.policy = new Policy({ store });
|
||||
this.policy = new Policy({ store, pubkey });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user