fix(api): return all privacy values so client can update them (#65620)

This commit is contained in:
Oliver Eyton-Williams
2026-01-31 13:35:41 +01:00
committed by GitHub
parent c7a37a98d2
commit 12082f5547
6 changed files with 37 additions and 39 deletions

View File

@@ -258,7 +258,15 @@ describe('userRoutes', () => {
const lockedUserProfileUI = {
isLocked: true,
showAbout: true,
showPortfolio: false
showCerts: true,
showDonation: true,
showExperience: true,
showHeatMap: true,
showLocation: true,
showName: true,
showPoints: true,
showPortfolio: true,
showTimeLine: true
};
const unlockedUserProfileUI = {
isLocked: false,

View File

@@ -1,20 +1,10 @@
import { Type } from '@fastify/type-provider-typebox';
import { profileUI } from '../types.js';
export const updateMyProfileUI = {
body: Type.Object({
profileUI: Type.Object({
isLocked: Type.Boolean(),
showAbout: Type.Boolean(),
showCerts: Type.Boolean(),
showDonation: Type.Boolean(),
showHeatMap: Type.Boolean(),
showLocation: Type.Boolean(),
showName: Type.Boolean(),
showPoints: Type.Boolean(),
showPortfolio: Type.Boolean(),
showExperience: Type.Boolean(),
showTimeLine: Type.Boolean()
})
profileUI
}),
response: {
200: Type.Object({

View File

@@ -70,17 +70,17 @@ export const surveyTitles = Type.Union([
]);
export const profileUI = Type.Object({
isLocked: Type.Optional(Type.Boolean()),
showAbout: Type.Optional(Type.Boolean()),
showCerts: Type.Optional(Type.Boolean()),
showDonation: Type.Optional(Type.Boolean()),
showHeatMap: Type.Optional(Type.Boolean()),
showLocation: Type.Optional(Type.Boolean()),
showName: Type.Optional(Type.Boolean()),
showPoints: Type.Optional(Type.Boolean()),
showPortfolio: Type.Optional(Type.Boolean()),
showTimeLine: Type.Optional(Type.Boolean()),
showExperience: Type.Optional(Type.Boolean())
isLocked: Type.Boolean(),
showAbout: Type.Boolean(),
showCerts: Type.Boolean(),
showDonation: Type.Boolean(),
showHeatMap: Type.Boolean(),
showLocation: Type.Boolean(),
showName: Type.Boolean(),
showPoints: Type.Boolean(),
showPortfolio: Type.Boolean(),
showTimeLine: Type.Boolean(),
showExperience: Type.Boolean()
});
export const experience = Type.Object({

View File

@@ -124,7 +124,7 @@ export const getSessionUser = {
})
),
experience: Type.Optional(Type.Array(experience)),
profileUI: Type.Optional(profileUI),
profileUI,
sendQuincyEmail: Type.Union([Type.Null(), Type.Boolean()]), // // Tri-state: null (likely new user), true (subscribed), false (unsubscribed)
theme: Type.String(),
twitter: Type.Optional(Type.String()),

View File

@@ -78,7 +78,7 @@ describe('normalize', () => {
expect(normalizeProfileUI(input)).toEqual(defaultProfileUI);
});
test('should convert all "null" values to "undefined"', () => {
test('should convert all "null" values to "false"', () => {
const input = {
isLocked: null,
showAbout: false,
@@ -93,17 +93,17 @@ describe('normalize', () => {
showExperience: null
};
expect(normalizeProfileUI(input)).toEqual({
isLocked: undefined,
isLocked: false,
showAbout: false,
showCerts: undefined,
showDonation: undefined,
showHeatMap: undefined,
showLocation: undefined,
showName: undefined,
showPoints: undefined,
showPortfolio: undefined,
showTimeLine: undefined,
showExperience: undefined
showCerts: false,
showDonation: false,
showHeatMap: false,
showLocation: false,
showName: false,
showPoints: false,
showPortfolio: false,
showTimeLine: false,
showExperience: false
});
});
});

View File

@@ -124,9 +124,9 @@ export const normalizeChallengeType = (
*/
export const normalizeProfileUI = (
maybeProfileUI: ProfileUI | null
): NoNullProperties<ProfileUI> => {
): DefaultToFalse<ProfileUI> => {
return maybeProfileUI
? removeNulls(maybeProfileUI)
? normalizeFlags(maybeProfileUI)
: {
isLocked: true,
showAbout: false,