mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-09-24 23:01:18 +08:00
fix(api): add needsModeration flag to user document root (#45921)
* fix(api): add needsModeration flag to user document root * fix prettiers complaints * Update api-server/src/common/models/user.json Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com> Co-authored-by: Tom <20648924+moT01@users.noreply.github.com> Co-authored-by: Naomi Carrigan <nhcarrigan@gmail.com>
This commit is contained in:
co-authored by
Naomi Carrigan
Tom
parent
8da87f4d58
commit
2717581b2f
@@ -120,6 +120,17 @@
|
||||
"description": "Camper has signed academic honesty policy",
|
||||
"default": false
|
||||
},
|
||||
"needsModeration": {
|
||||
"type": "boolean",
|
||||
"description": "Camper has challenges needing to be moderated",
|
||||
"default": false,
|
||||
"index": {
|
||||
"mongodb": {
|
||||
"unique": true,
|
||||
"background": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"isFrontEndCert": {
|
||||
"type": "boolean",
|
||||
"description": "Camper is front end certified",
|
||||
|
||||
@@ -145,7 +145,11 @@ export function buildUserUpdate(
|
||||
}
|
||||
let finalChallenge;
|
||||
const updateData = {};
|
||||
const { timezone: userTimezone, completedChallenges = [] } = user;
|
||||
const {
|
||||
timezone: userTimezone,
|
||||
completedChallenges = [],
|
||||
needsModeration = false
|
||||
} = user;
|
||||
|
||||
const oldChallenge = find(
|
||||
completedChallenges,
|
||||
@@ -210,6 +214,14 @@ export function buildUserUpdate(
|
||||
timezone: userTimezone
|
||||
};
|
||||
}
|
||||
|
||||
if (needsModeration) {
|
||||
updateData.$set = {
|
||||
...updateData.$set,
|
||||
needsModeration: true
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
alreadyCompleted,
|
||||
updateData,
|
||||
@@ -309,6 +321,7 @@ export function modernChallengeCompleted(req, res, next) {
|
||||
// if multifile cert project
|
||||
if (challengeType === 14) {
|
||||
completedChallenge.isManuallyApproved = false;
|
||||
user.needsModeration = true;
|
||||
}
|
||||
|
||||
// We only need to know the challenge type if it's a project. If it's a
|
||||
|
||||
Reference in New Issue
Block a user