pl-api: update interaction policies API
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -17,10 +17,21 @@ const interactionPolicyEntrySchema = v.picklist([
|
||||
*/
|
||||
type InteractionPolicyEntry = v.InferOutput<typeof interactionPolicyEntrySchema>;
|
||||
|
||||
const interactionPolicyRuleSchema = coerceObject({
|
||||
always: v.fallback(v.array(interactionPolicyEntrySchema), ['public', 'me']),
|
||||
with_approval: v.fallback(v.array(interactionPolicyEntrySchema), []),
|
||||
});
|
||||
const interactionPolicyRuleSchema = v.optional(
|
||||
v.pipe(
|
||||
v.any(),
|
||||
v.transform((rule) => {
|
||||
if (rule.always) rule.automatic_approval = rule.always;
|
||||
if (rule.with_approval) rule.manual_approval = rule.with_approval;
|
||||
return rule;
|
||||
}),
|
||||
v.object({
|
||||
automatic_approval: v.fallback(v.array(interactionPolicyEntrySchema), ['public', 'me']),
|
||||
manual_approval: v.fallback(v.array(interactionPolicyEntrySchema), []),
|
||||
}),
|
||||
),
|
||||
{},
|
||||
);
|
||||
|
||||
/**
|
||||
* @category Schemas
|
||||
|
||||
@ -204,7 +204,7 @@ type UpdateInteractionPoliciesParams = Record<
|
||||
Record<
|
||||
'can_favourite' | 'can_reblog' | 'can_reply',
|
||||
Record<
|
||||
'always' | 'with_approval',
|
||||
'automatic_approval' | 'manual_approval',
|
||||
Array<
|
||||
'public' | 'followers' | 'following' | 'mutuals' | 'mentioned' | 'author' | 'me' | string
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user