mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Ensured group tasks are removed from places that challegnes tasks are (#8359)
* Ensured group tasks are removed from places that challegnes tasks are * Added tests for user reset and class cast
This commit is contained in:
committed by
Matteo Pagliazzi
parent
28e8ec2d2c
commit
857aa5827b
@@ -917,6 +917,8 @@ api.clearCompletedTodos = {
|
||||
$or: [
|
||||
{'challenge.id': {$exists: false}},
|
||||
{'challenge.broken': {$exists: true}},
|
||||
{'group.id': {$exists: false}},
|
||||
{'group.broken': {$exists: true}},
|
||||
],
|
||||
}).exec();
|
||||
|
||||
|
||||
@@ -372,6 +372,7 @@ api.castSpell = {
|
||||
}).exec();
|
||||
if (!task) throw new NotFound(res.t('taskNotFound'));
|
||||
if (task.challenge.id) throw new BadRequest(res.t('challengeTasksNoCast'));
|
||||
if (task.group.id) throw new BadRequest(res.t('groupTasksNoCast'));
|
||||
|
||||
spell.cast(user, task, req);
|
||||
|
||||
@@ -394,6 +395,8 @@ api.castSpell = {
|
||||
$or: [ // exclude challenge tasks
|
||||
{'challenge.id': {$exists: false}},
|
||||
{'challenge.broken': {$exists: true}},
|
||||
{'group.id': {$exists: false}},
|
||||
{'group.broken': {$exists: true}},
|
||||
],
|
||||
}).exec();
|
||||
|
||||
@@ -1055,6 +1058,8 @@ api.userRebirth = {
|
||||
$or: [ // exclude challenge tasks
|
||||
{'challenge.id': {$exists: false}},
|
||||
{'challenge.broken': {$exists: true}},
|
||||
{'group.id': {$exists: false}},
|
||||
{'group.broken': {$exists: true}},
|
||||
],
|
||||
}).exec();
|
||||
|
||||
@@ -1171,6 +1176,8 @@ api.userReroll = {
|
||||
$or: [ // exclude challenge tasks
|
||||
{'challenge.id': {$exists: false}},
|
||||
{'challenge.broken': {$exists: true}},
|
||||
{'group.id': {$exists: false}},
|
||||
{'group.broken': {$exists: true}},
|
||||
],
|
||||
};
|
||||
let tasks = await Tasks.Task.find(query).exec();
|
||||
@@ -1206,8 +1213,10 @@ api.userReset = {
|
||||
$or: [ // exclude challenge tasks
|
||||
{'challenge.id': {$exists: false}},
|
||||
{'challenge.broken': {$exists: true}},
|
||||
{'group.id': {$exists: false}},
|
||||
{'group.broken': {$exists: true}},
|
||||
],
|
||||
}).select('_id type challenge').exec();
|
||||
}).select('_id type challenge group').exec();
|
||||
|
||||
let resetRes = common.ops.reset(user, tasks);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user