bigbuffet-rw/packages/pl-api/lib/entities/interaction-policy.ts
marcin mikołajczak d91b55d9b1 cleanup
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-29 22:48:58 +02:00

31 lines
1.1 KiB
TypeScript

import { z } from 'zod';
import { coerceObject } from './utils';
const interactionPolicyEntrySchema = z.enum(['public', 'followers', 'following', 'mutuals', 'mentioned', 'author', 'me']);
const interactionPolicyRuleSchema = coerceObject({
always: z.array(interactionPolicyEntrySchema).default(['public']),
with_approval: z.array(interactionPolicyEntrySchema).default([]),
});
/** @see {@link https://docs.gotosocial.org/en/latest/api/swagger/} */
const interactionPolicySchema = coerceObject({
can_favourite: interactionPolicyRuleSchema,
can_reblog: interactionPolicyRuleSchema,
can_reply: interactionPolicyRuleSchema,
});
type InteractionPolicy = z.infer<typeof interactionPolicySchema>;
const interactionPoliciesSchema = coerceObject({
public: interactionPolicySchema,
unlisted: interactionPolicySchema,
private: interactionPolicySchema,
direct: interactionPolicySchema,
});
type InteractionPolicies = z.infer<typeof interactionPoliciesSchema>;
export { interactionPolicySchema, interactionPoliciesSchema, type InteractionPolicy, type InteractionPolicies };