mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Node 12 (#11149)
* chore(node): upgrade to version 12 * update package-lock.json * upgrade bcrypt * upgrade node-sass * update deps * fix deprecation * downgrade amplitude * fix client side tests * fix common and integration tests, upgrade mongoose
This commit is contained in:
@@ -37,6 +37,23 @@ export const taskIsGroupOrChallengeQuery = {
|
||||
],
|
||||
};
|
||||
|
||||
const reminderSchema = new Schema({
|
||||
_id: false,
|
||||
id: {$type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true},
|
||||
startDate: {$type: Date},
|
||||
time: {$type: Date, required: true},
|
||||
}, {
|
||||
strict: true,
|
||||
minimize: false, // So empty objects are returned
|
||||
_id: false,
|
||||
typeKey: '$type', // So that we can use a field named `type`
|
||||
});
|
||||
|
||||
reminderSchema.plugin(baseModel, {
|
||||
noSet: ['_id', 'id'],
|
||||
_id: false,
|
||||
});
|
||||
|
||||
// Important
|
||||
// When something changes here remember to update the client side model at common/script/libs/taskDefaults
|
||||
export let TaskSchema = new Schema({
|
||||
@@ -57,20 +74,14 @@ export let TaskSchema = new Schema({
|
||||
},
|
||||
msg: 'Task short names cannot be uuids.',
|
||||
}, {
|
||||
validator (alias) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Task.findOne({ // eslint-disable-line no-use-before-define
|
||||
_id: { $ne: this._id },
|
||||
userId: this.userId,
|
||||
alias,
|
||||
}).exec().then((task) => {
|
||||
let aliasAvailable = !task;
|
||||
async validator (alias) {
|
||||
const taskDuplicated = await Task.findOne({ // eslint-disable-line no-use-before-define
|
||||
_id: { $ne: this._id },
|
||||
userId: this.userId,
|
||||
alias,
|
||||
}).exec();
|
||||
|
||||
return aliasAvailable ? resolve() : reject();
|
||||
}).catch(() => {
|
||||
reject();
|
||||
});
|
||||
});
|
||||
return taskDuplicated ? false : true;
|
||||
},
|
||||
msg: 'Task alias already used on another task.',
|
||||
}],
|
||||
@@ -116,12 +127,7 @@ export let TaskSchema = new Schema({
|
||||
sharedCompletion: {$type: String, enum: _.values(SHARED_COMPLETION), default: SHARED_COMPLETION.single},
|
||||
},
|
||||
|
||||
reminders: [{
|
||||
_id: false,
|
||||
id: {$type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true},
|
||||
startDate: {$type: Date},
|
||||
time: {$type: Date, required: true},
|
||||
}],
|
||||
reminders: [reminderSchema],
|
||||
}, _.defaults({
|
||||
minimize: false, // So empty objects are returned
|
||||
strict: true,
|
||||
|
||||
Reference in New Issue
Block a user