mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
clean up some confusing naming around policy specs
This commit is contained in:
parent
72685f227b
commit
5e98bc65c0
2 changed files with 15 additions and 13 deletions
|
|
@ -152,7 +152,7 @@ import pleromaAdminPermissionGroupsRoute from '@/routes/pleromaAdminPermissionGr
|
|||
import pleromaStatusesRoute from '@/routes/pleromaStatusesRoute.ts';
|
||||
import { DittoRelayStore } from '@/storages/DittoRelayStore.ts';
|
||||
import { adminListPoliciesController, adminCurrentPolicyController } from '@/controllers/api/policies.ts';
|
||||
import { createPolicyEvent, DEFAULT_POLICIES } from '@/utils/policies.ts';
|
||||
import { createPolicyEvent, DEFAULT_POLICY_SPEC } from '@/utils/policies.ts';
|
||||
|
||||
export interface AppEnv extends DittoEnv {
|
||||
Variables: DittoEnv['Variables'] & {
|
||||
|
|
@ -201,8 +201,8 @@ const pool = new DittoPool({ conf, relay: pgstore });
|
|||
const relay = new DittoRelayStore({ db, conf, pool, relay: pgstore });
|
||||
const havePolicy = await relay.count([{ kinds: [11984], authors: [await conf.signer.getPublicKey()] }]);
|
||||
|
||||
if (!havePolicy) {
|
||||
relay.event(await createPolicyEvent(conf, { policies: DEFAULT_POLICIES }));
|
||||
if (!havePolicy.count) {
|
||||
await relay.event(await createPolicyEvent(conf, DEFAULT_POLICY_SPEC));
|
||||
}
|
||||
|
||||
await seedZapSplits({ conf, relay });
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@ export interface PolicySpec {
|
|||
policies: PolicySpecItem[]
|
||||
}
|
||||
|
||||
export const DEFAULT_POLICIES: PolicySpecItem[] = [
|
||||
export const DEFAULT_POLICY_SPEC: PolicySpec = {
|
||||
policies: [
|
||||
{ "name": "AntiDuplicationPolicy" },
|
||||
{ "name": "AuthorPolicy" },
|
||||
{ "name": "DomainPolicy" },
|
||||
|
|
@ -31,12 +32,13 @@ export const DEFAULT_POLICIES: PolicySpecItem[] = [
|
|||
{ "name": "ReplyBotPolicy" },
|
||||
{ "name": "SizePolicy" },
|
||||
{ "name": "HashtagPolicy", "params": { "hashtags": ["NSFW", "explicit", "violence", "cp", "porn"] } },
|
||||
];
|
||||
]
|
||||
};
|
||||
|
||||
export const createPolicyEvent = async (conf: DittoConf, policies: PolicySpec) => {
|
||||
return await conf.signer.signEvent({
|
||||
kind: 11984,
|
||||
content: JSON.stringify({ policies }),
|
||||
content: JSON.stringify(policies),
|
||||
created_at: nostrNow(),
|
||||
tags: []
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue