|
|
|
@ -34,6 +34,14 @@ const linkItemSchema = z.object({ |
|
|
|
icon: socialLinkIconSchema.optional(), |
|
|
|
}); |
|
|
|
|
|
|
|
const discoverLocationPatchSchema = z.union([ |
|
|
|
z.null(), |
|
|
|
z.string().max(200).transform((s) => { |
|
|
|
const t = s.trim(); |
|
|
|
return t.length > 0 ? t : null; |
|
|
|
}), |
|
|
|
]); |
|
|
|
|
|
|
|
export type SocialLinkItem = z.infer<typeof linkItemSchema>; |
|
|
|
|
|
|
|
export async function getProfileRow(userId: number) { |
|
|
|
@ -51,6 +59,9 @@ export async function updateProfile( |
|
|
|
bioVisibility?: Visibility; |
|
|
|
socialLinks?: SocialLinkItem[]; |
|
|
|
publicSlug?: string | null; |
|
|
|
discoverVisible?: boolean; |
|
|
|
discoverLocation?: string | null; |
|
|
|
discoverShowLocation?: boolean; |
|
|
|
}, |
|
|
|
) { |
|
|
|
const updates: Record<string, unknown> = {}; |
|
|
|
@ -81,6 +92,15 @@ export async function updateProfile( |
|
|
|
updates.publicSlug = publicSlugValue.parse(patch.publicSlug.trim().toLowerCase()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (patch.discoverVisible !== undefined) { |
|
|
|
updates.discoverVisible = patch.discoverVisible; |
|
|
|
} |
|
|
|
if (patch.discoverLocation !== undefined) { |
|
|
|
updates.discoverLocation = discoverLocationPatchSchema.parse(patch.discoverLocation); |
|
|
|
} |
|
|
|
if (patch.discoverShowLocation !== undefined) { |
|
|
|
updates.discoverShowLocation = patch.discoverShowLocation; |
|
|
|
} |
|
|
|
|
|
|
|
if (Object.keys(updates).length === 0) { |
|
|
|
return getProfileRow(userId); |
|
|
|
|