groupSchema: refine --> transform, fix type of members_count

This commit is contained in:
Alex Gleason 2023-03-10 13:13:54 -06:00
parent 6be8d4d46e
commit 5e8c92ed4d
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 3 additions and 3 deletions

View File

@ -24,13 +24,13 @@ const groupSchema = z.object({
id: z.string().catch(''), id: z.string().catch(''),
locked: z.boolean().catch(false), locked: z.boolean().catch(false),
membership_required: z.boolean().catch(false), membership_required: z.boolean().catch(false),
members_count: z.number().optional().catch(undefined), members_count: z.number().catch(0),
note: z.string().catch('').refine(note => note === '<p></p>' ? '' : note), note: z.string().catch('').refine(note => note === '<p></p>' ? '' : note),
relationship: groupRelationshipSchema.optional().catch(undefined), // Dummy field to be overwritten later relationship: groupRelationshipSchema.nullable().catch(null), // Dummy field to be overwritten later
statuses_visibility: z.string().catch('public'), statuses_visibility: z.string().catch('public'),
uri: z.string().catch(''), uri: z.string().catch(''),
url: z.string().catch(''), url: z.string().catch(''),
}).refine(group => { }).transform(group => {
group.avatar_static = group.avatar_static || group.avatar; group.avatar_static = group.avatar_static || group.avatar;
group.header_static = group.header_static || group.header; group.header_static = group.header_static || group.header;
group.locked = group.locked || group.group_visibility === 'members_only'; // TruthSocial group.locked = group.locked || group.group_visibility === 'members_only'; // TruthSocial