Merge branch 'release' into develop

This commit is contained in:
SabreCat 2022-08-29 15:51:45 -05:00
commit 14441701c9
8 changed files with 16 additions and 23 deletions

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "habitica",
"version": "4.241.2",
"version": "4.241.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -1,7 +1,7 @@
{
"name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "4.241.2",
"version": "4.241.4",
"main": "./website/server/index.js",
"dependencies": {
"@babel/core": "^7.18.13",

View file

@ -152,9 +152,9 @@ describe('POST /user/class/cast/:spellId', () => {
await expect(groupLeader.post(`/user/class/cast/pickPocket?targetId=${groupTask._id}`))
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('groupTasksNoCast'),
code: 404,
error: 'NotFound',
message: t('messageTaskNotFound'),
});
});

View file

@ -137,9 +137,9 @@ describe('POST /user/class/cast/:spellId', () => {
await expect(groupLeader.post(`/user/class/cast/pickPocket?targetId=${groupTask._id}`))
.to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('groupTasksNoCast'),
code: 404,
error: 'NotFound',
message: t('messageTaskNotFound'),
});
});

View file

@ -84,7 +84,8 @@ export function canEdit (store) {
const user = store.state.user.data;
const userId = user.id || user._id;
const isUserAdmin = user.permissions && user.permissions.challengeAdmin;
const isUserAdmin = user.permissions
&& (user.permissions.challengeAdmin || user.permissions.fullAccess);
const isUserGroupLeader = group && (group.leader
&& group.leader._id === userId);
const isUserGroupManager = group && (group.managers

View file

@ -21,6 +21,7 @@ async function castTaskSpell (res, req, targetId, user, spell, quantity = 1) {
if (!targetId) throw new BadRequest(res.t('targetIdUUID'));
const task = await Tasks.Task.findOne({
userId: user._id,
_id: targetId,
}).exec();
if (!task) throw new NotFound(res.t('messageTaskNotFound'));

View file

@ -138,7 +138,7 @@ export async function update (req, res, { isV3 = false }) {
if (!Array.isArray(groupsToMirror)) {
throw new BadRequest('Groups to copy tasks from must be an array.');
}
const memberGroups = user.guilds;
const memberGroups = _.clone(user.guilds);
if (user.party._id) memberGroups.push(user.party._id);
for (const targetGroup of groupsToMirror) {
if (memberGroups.indexOf(targetGroup) === -1) {

View file

@ -74,19 +74,10 @@ async function cronAsync (req, res) {
}
const tasks = await Tasks.Task.find({
$and: [
{
$or: [
{ userId: user._id },
{ userId: { $exists: false }, 'group.assignedUsers': user._id },
],
},
{
$or: [ // Exclude completed todos
{ type: 'todo', completed: false },
{ type: { $in: ['habit', 'daily', 'reward'] } },
],
},
userId: user._id,
$or: [ // Exclude completed todos
{ type: 'todo', completed: false },
{ type: { $in: ['habit', 'daily'] } },
],
}).exec();