2024-08-28 04:43:23 -07:00
|
|
|
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,
|
|
|
|
});
|
|
|
|
|
2024-08-29 13:48:58 -07:00
|
|
|
type InteractionPolicy = z.infer<typeof interactionPolicySchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
const interactionPoliciesSchema = coerceObject({
|
|
|
|
public: interactionPolicySchema,
|
|
|
|
unlisted: interactionPolicySchema,
|
|
|
|
private: interactionPolicySchema,
|
|
|
|
direct: interactionPolicySchema,
|
|
|
|
});
|
|
|
|
|
2024-08-29 13:48:58 -07:00
|
|
|
type InteractionPolicies = z.infer<typeof interactionPoliciesSchema>;
|
2024-08-28 04:43:23 -07:00
|
|
|
|
|
|
|
export { interactionPolicySchema, interactionPoliciesSchema, type InteractionPolicy, type InteractionPolicies };
|
|
|
|
|