Merge branch 'develop' into report-profile-modal

This commit is contained in:
CuriousMagpie
2023-08-23 11:52:08 -04:00
98 changed files with 1627 additions and 1740 deletions
@@ -575,13 +575,15 @@ api.getChallenge = {
// Fetching basic group data
const group = await Group.getGroup({
user, groupId: challenge.group, fields: `${basicGroupFields} purchased`, optionalMembership: true,
user, groupId: challenge.group, fields: `${basicGroupFields} purchased`,
});
if (!group || !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
group.purchased = undefined;
if (!group && !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
const chalRes = challenge.toJSON();
chalRes.group = group.toJSON({ minimize: true });
if (group) {
group.purchased = undefined;
chalRes.group = group.toJSON({ minimize: true });
}
// Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833
const chalLeader = await User.findById(chalRes.leader).select(nameFields).exec();
chalRes.leader = chalLeader ? chalLeader.toJSON({ minimize: true }) : null;
+1 -1
View File
@@ -321,7 +321,7 @@ api.getGroups = {
throw new BadRequest(apiError('guildsOnlyPaginate'));
}
const groupFields = basicGroupFields.concat(' description memberCount balance');
const groupFields = basicGroupFields.concat(' description memberCount balance leaderOnly');
const sort = '-memberCount';
const filters = {};
+2 -3
View File
@@ -461,10 +461,9 @@ api.getChallengeTasks = {
const group = await Group.getGroup({
user,
groupId: challenge.group,
fields: '_id type privacy',
optionalMembership: true,
fields: '_id type privacy purchased',
});
if (!group || !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
if (!group && !challenge.canView(user, group)) throw new NotFound(res.t('challengeNotFound'));
const tasks = await getTasks(req, res, { user, challenge });
return res.respond(200, tasks);