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 pleromaStatusesRoute from '@/routes/pleromaStatusesRoute.ts';
|
||||||
import { DittoRelayStore } from '@/storages/DittoRelayStore.ts';
|
import { DittoRelayStore } from '@/storages/DittoRelayStore.ts';
|
||||||
import { adminListPoliciesController, adminCurrentPolicyController } from '@/controllers/api/policies.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 {
|
export interface AppEnv extends DittoEnv {
|
||||||
Variables: DittoEnv['Variables'] & {
|
Variables: DittoEnv['Variables'] & {
|
||||||
|
|
@ -201,8 +201,8 @@ const pool = new DittoPool({ conf, relay: pgstore });
|
||||||
const relay = new DittoRelayStore({ db, conf, pool, relay: pgstore });
|
const relay = new DittoRelayStore({ db, conf, pool, relay: pgstore });
|
||||||
const havePolicy = await relay.count([{ kinds: [11984], authors: [await conf.signer.getPublicKey()] }]);
|
const havePolicy = await relay.count([{ kinds: [11984], authors: [await conf.signer.getPublicKey()] }]);
|
||||||
|
|
||||||
if (!havePolicy) {
|
if (!havePolicy.count) {
|
||||||
relay.event(await createPolicyEvent(conf, { policies: DEFAULT_POLICIES }));
|
await relay.event(await createPolicyEvent(conf, DEFAULT_POLICY_SPEC));
|
||||||
}
|
}
|
||||||
|
|
||||||
await seedZapSplits({ conf, relay });
|
await seedZapSplits({ conf, relay });
|
||||||
|
|
|
||||||
|
|
@ -23,20 +23,22 @@ export interface PolicySpec {
|
||||||
policies: PolicySpecItem[]
|
policies: PolicySpecItem[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_POLICIES: PolicySpecItem[] = [
|
export const DEFAULT_POLICY_SPEC: PolicySpec = {
|
||||||
{ "name": "AntiDuplicationPolicy" },
|
policies: [
|
||||||
{ "name": "AuthorPolicy" },
|
{ "name": "AntiDuplicationPolicy" },
|
||||||
{ "name": "DomainPolicy" },
|
{ "name": "AuthorPolicy" },
|
||||||
{ "name": "HellthreadPolicy" },
|
{ "name": "DomainPolicy" },
|
||||||
{ "name": "ReplyBotPolicy" },
|
{ "name": "HellthreadPolicy" },
|
||||||
{ "name": "SizePolicy" },
|
{ "name": "ReplyBotPolicy" },
|
||||||
{ "name": "HashtagPolicy", "params": { "hashtags": ["NSFW", "explicit", "violence", "cp", "porn"] } },
|
{ "name": "SizePolicy" },
|
||||||
];
|
{ "name": "HashtagPolicy", "params": { "hashtags": ["NSFW", "explicit", "violence", "cp", "porn"] } },
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
export const createPolicyEvent = async (conf: DittoConf, policies: PolicySpec) => {
|
export const createPolicyEvent = async (conf: DittoConf, policies: PolicySpec) => {
|
||||||
return await conf.signer.signEvent({
|
return await conf.signer.signEvent({
|
||||||
kind: 11984,
|
kind: 11984,
|
||||||
content: JSON.stringify({ policies }),
|
content: JSON.stringify(policies),
|
||||||
created_at: nostrNow(),
|
created_at: nostrNow(),
|
||||||
tags: []
|
tags: []
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue