mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
26 lines
876 B
TypeScript
26 lines
876 B
TypeScript
import { policyRegistry, type AppController } from '@/app.ts';
|
|
import { DEFAULT_POLICIES } from "@/utils/policies.ts";
|
|
|
|
export const adminListPoliciesController: AppController = (c) => {
|
|
return c.json(Object.entries(policyRegistry.policies)
|
|
.map(([internalName, item]) => {
|
|
return {
|
|
internalName,
|
|
...item,
|
|
instantiate: undefined,
|
|
}
|
|
}))
|
|
};
|
|
|
|
export const adminCurrentPolicyController: AppController = async (c) => {
|
|
const { relay, conf } = c.var;
|
|
const pubkey = await conf.signer.getPublicKey();
|
|
|
|
const current = await relay.query([{
|
|
authors: [pubkey],
|
|
kinds: [11984]
|
|
}]).then(events => events[0]);
|
|
|
|
if (current) return c.json({ mode: conf.policyMode, policies: current });
|
|
return c.json({ mode: conf.policyMode, policies: DEFAULT_POLICIES });
|
|
}
|