do not create a default policy spec in get controller

This commit is contained in:
Siddharth Singh 2025-05-06 19:24:13 +05:30
parent ca1c0a8240
commit 42f581d350
No known key found for this signature in database
2 changed files with 2 additions and 5 deletions

View file

@ -1,6 +1,6 @@
import { type AppController } from '@/app.ts'; import { type AppController } from '@/app.ts';
import { createPolicyEvent } from '@/utils/policies/mod.ts'; import { createPolicyEvent } from '@/utils/policies/mod.ts';
import { DEFAULT_POLICY_SPEC, policyRegistry } from '@/utils/policies/mod.ts'; import { policyRegistry } from '@/utils/policies/mod.ts';
import { z } from 'zod'; import { z } from 'zod';
export const adminListPoliciesController: AppController = (c) => { export const adminListPoliciesController: AppController = (c) => {
@ -27,9 +27,7 @@ export const adminCurrentPolicyController: AppController = async (c) => {
}]).then((events) => events[0]); }]).then((events) => events[0]);
if (current) return c.json({ spec: JSON.parse(current.content) }); if (current) return c.json({ spec: JSON.parse(current.content) });
return c.json({ spec: { policies: [] } });
await relay.event(await createPolicyEvent(conf, DEFAULT_POLICY_SPEC));
return c.json({ spec: DEFAULT_POLICY_SPEC });
}; };
const PolicySpecSchema = z.object({ const PolicySpecSchema = z.object({

View file

@ -37,7 +37,6 @@ export const DEFAULT_POLICY_SPEC: PolicySpec = {
policies: [ policies: [
{ 'name': 'SizePolicy' }, { 'name': 'SizePolicy' },
{ 'name': 'HellthreadPolicy' }, { 'name': 'HellthreadPolicy' },
{ 'name': 'HashtagPolicy', 'params': { 'hashtags': ['NSFW', 'explicit', 'violence', 'cp', 'porn'] } },
{ 'name': 'ReplyBotPolicy' }, { 'name': 'ReplyBotPolicy' },
{ 'name': 'AntiDuplicationPolicy' }, { 'name': 'AntiDuplicationPolicy' },
], ],