mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 13:47:33 +01:00
Filter challenge by owned (#12527)
* when filtering by owned challenges, challenges that a user owns but has not joined will be included * add tests for filtering challenges by owned * fix lint
This commit is contained in:
@@ -371,10 +371,7 @@ api.getUserChallenges = {
|
||||
{ _id: { $in: user.challenges } }, // Challenges where the user is participating
|
||||
];
|
||||
|
||||
const { owned } = req.query;
|
||||
if (!owned) {
|
||||
orOptions.push({ leader: user._id });
|
||||
}
|
||||
orOptions.push({ leader: user._id });
|
||||
|
||||
if (!req.query.member) {
|
||||
orOptions.push({
|
||||
@@ -386,6 +383,7 @@ api.getUserChallenges = {
|
||||
$and: [{ $or: orOptions }],
|
||||
};
|
||||
|
||||
const { owned } = req.query;
|
||||
if (owned) {
|
||||
if (owned === 'not_owned') {
|
||||
query.$and.push({ leader: { $ne: user._id } });
|
||||
|
||||
Reference in New Issue
Block a user