mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
Upgrade mongoose (#10767)
* fix mongoose and upgrade * fix more validations
This commit is contained in:
120
package-lock.json
generated
120
package-lock.json
generated
@@ -14761,9 +14761,9 @@
|
|||||||
"integrity": "sha512-KEyanRIDHooo8KuBxY3CC019NbwHtxdsxzRJUfaGqcxMrvBPBkosN+RUxx1nZFI6yrErq3KTW8HI/qrNIxHe0g=="
|
"integrity": "sha512-KEyanRIDHooo8KuBxY3CC019NbwHtxdsxzRJUfaGqcxMrvBPBkosN+RUxx1nZFI6yrErq3KTW8HI/qrNIxHe0g=="
|
||||||
},
|
},
|
||||||
"kareem": {
|
"kareem": {
|
||||||
"version": "2.1.0",
|
"version": "2.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/kareem/-/kareem-2.3.0.tgz",
|
||||||
"integrity": "sha512-ycoMY1tVkcH1/NaxGn2erZaUC3CodmX7Fl6DUVXjN73+uecWYTaaldRkxNY3HeSKQnQTWnoxRKnZfVHcB8tIWg=="
|
"integrity": "sha512-6hHxsp9e6zQU8nXsP+02HGWXwTkOEw6IROhF2ZA28cYbUk4eJ6QbtZvdqZOdD9YPKghG3apk5eOCvs+tLl3lRg=="
|
||||||
},
|
},
|
||||||
"karma": {
|
"karma": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
@@ -16768,6 +16768,12 @@
|
|||||||
"readable-stream": "^2.0.1"
|
"readable-stream": "^2.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"memory-pager": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-Mf9OHV/Y7h6YWDxTzX/b4ZZ4oh9NSXblQL8dtPCOomOtZciEHxePR78+uHFLLlsk01A6jVHhHsQZZ/WcIPpnzg==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"memwatch-next": {
|
"memwatch-next": {
|
||||||
"version": "0.3.0",
|
"version": "0.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/memwatch-next/-/memwatch-next-0.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/memwatch-next/-/memwatch-next-0.3.0.tgz",
|
||||||
@@ -17233,46 +17239,58 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mongodb": {
|
"mongodb": {
|
||||||
"version": "3.0.8",
|
"version": "3.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.6.tgz",
|
||||||
"integrity": "sha512-mj7yIUyAr9xnO2ev8pcVJ9uX7gSum5LLs1qIFoWLxA5Il50+jcojKtaO1/TbexsScZ9Poz00Pc3b86GiSqJ7WA==",
|
"integrity": "sha512-E5QJuXQoMlT7KyCYqNNMfAkhfQD79AT4F8Xd+6x37OX+8BL17GyXyWvfm6wuyx4wnzCCPoCSLeMeUN2S7dU9yw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"mongodb-core": "3.0.8"
|
"mongodb-core": "3.1.5",
|
||||||
|
"safe-buffer": "^5.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mongodb-core": {
|
"mongodb-core": {
|
||||||
"version": "3.0.8",
|
"version": "3.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.5.tgz",
|
||||||
"integrity": "sha512-dFxfhH9N7ohuQnINyIl6dqEF8sYOE0WKuymrFf3L3cipJNrx+S8rAbNOTwa00/fuJCjBMJNFsaA+R2N16//UIw==",
|
"integrity": "sha512-emT/tM4ZBinqd6RZok+EzDdtN4LjYJIckv71qQVOEFmvXgT5cperZegVmTgox/1cx4XQu6LJ5ZuIwipP/eKdQg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bson": "~1.0.4",
|
"bson": "^1.1.0",
|
||||||
"require_optional": "^1.0.1"
|
"require_optional": "^1.0.1",
|
||||||
|
"safe-buffer": "^5.1.2",
|
||||||
|
"saslprep": "^1.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"bson": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-9Aeai9TacfNtWXOYarkFJRW2CWo+dRon+fuLZYJmvLV3+MiUp0bEI6IAZfXEIg7/Pl/7IWlLaDnhzTsD81etQA=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mongoose": {
|
"mongoose": {
|
||||||
"version": "5.1.3",
|
"version": "5.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-5.3.4.tgz",
|
||||||
"integrity": "sha512-v+hHI/NxJtcVPm2cY+/kJfTfkkXVCz/le0iVdnh3enGi+fClhoaztjTtXQMdzIzNc+M0R93KcARpzvPQq/cWKQ==",
|
"integrity": "sha512-DIUWOyYgZv2zGi/BoFEaFiaCVuDonnzGhW3cnc3JFjBScYn6z24tS2j3VB0dtMoX8FFjxmmMVnlmHPEIbV4PKA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"async": "2.1.4",
|
"async": "2.6.1",
|
||||||
"bson": "~1.0.5",
|
"bson": "~1.0.5",
|
||||||
"kareem": "2.1.0",
|
"kareem": "2.3.0",
|
||||||
"lodash.get": "4.4.2",
|
"lodash.get": "4.4.2",
|
||||||
"mongodb": "3.0.8",
|
"mongodb": "3.1.6",
|
||||||
|
"mongodb-core": "3.1.5",
|
||||||
"mongoose-legacy-pluralize": "1.0.2",
|
"mongoose-legacy-pluralize": "1.0.2",
|
||||||
"mpath": "0.4.1",
|
"mpath": "0.5.1",
|
||||||
"mquery": "3.0.0",
|
"mquery": "3.2.0",
|
||||||
"ms": "2.0.0",
|
"ms": "2.0.0",
|
||||||
"regexp-clone": "0.0.1",
|
"regexp-clone": "0.0.1",
|
||||||
|
"safe-buffer": "5.1.2",
|
||||||
"sliced": "1.0.1"
|
"sliced": "1.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": {
|
"async": {
|
||||||
"version": "2.1.4",
|
"version": "2.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/async/-/async-2.1.4.tgz",
|
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
|
||||||
"integrity": "sha1-LSFgx3iAMuTdbL4lAvH5osj2zeQ=",
|
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"lodash": "^4.14.0"
|
"lodash": "^4.17.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17417,30 +17435,34 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mpath": {
|
"mpath": {
|
||||||
"version": "0.4.1",
|
"version": "0.5.1",
|
||||||
"resolved": "http://registry.npmjs.org/mpath/-/mpath-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/mpath/-/mpath-0.5.1.tgz",
|
||||||
"integrity": "sha512-NNY/MpBkALb9jJmjpBlIi6GRoLveLUM0pJzgbp9vY9F7IQEb/HREC/nxrixechcQwd1NevOhJnWWV8QQQRE+OA=="
|
"integrity": "sha512-H8OVQ+QEz82sch4wbODFOz+3YQ61FYz/z3eJ5pIdbMEaUzDqA268Wd+Vt4Paw9TJfvDgVKaayC0gBzMIw2jhsg=="
|
||||||
},
|
},
|
||||||
"mquery": {
|
"mquery": {
|
||||||
"version": "3.0.0",
|
"version": "3.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/mquery/-/mquery-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/mquery/-/mquery-3.2.0.tgz",
|
||||||
"integrity": "sha512-WL1Lk8v4l8VFSSwN3yCzY9TXw+fKVYKn6f+w86TRzOLSE8k1yTgGaLBPUByJQi8VcLbOdnUneFV/y3Kv874pnQ==",
|
"integrity": "sha512-qPJcdK/yqcbQiKoemAt62Y0BAc0fTEKo1IThodBD+O5meQRJT/2HSe5QpBNwaa4CjskoGrYWsEyjkqgiE0qjhg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bluebird": "3.5.0",
|
"bluebird": "3.5.1",
|
||||||
"debug": "2.6.9",
|
"debug": "3.1.0",
|
||||||
"regexp-clone": "0.0.1",
|
"regexp-clone": "0.0.1",
|
||||||
"sliced": "0.0.5"
|
"safe-buffer": "5.1.2",
|
||||||
|
"sliced": "1.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bluebird": {
|
"bluebird": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz",
|
||||||
"integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw="
|
"integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA=="
|
||||||
},
|
},
|
||||||
"sliced": {
|
"debug": {
|
||||||
"version": "0.0.5",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/sliced/-/sliced-0.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||||
"integrity": "sha1-XtwETKTrb3gW1Qui/GPiXY/kcH8="
|
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||||
|
"requires": {
|
||||||
|
"ms": "2.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -23387,6 +23409,15 @@
|
|||||||
"integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==",
|
"integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"saslprep": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-4cDsYuAjXssUSjxHKRe4DTZC0agDwsCqcMqtJAQPzC74nJ7LfAJflAtC1Zed5hMzEQKj82d3tuzqdGNRsLJ4Gw==",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"sparse-bitfield": "^3.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sass-graph": {
|
"sass-graph": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/sass-graph/-/sass-graph-2.2.4.tgz",
|
||||||
@@ -24122,6 +24153,15 @@
|
|||||||
"resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/sparkles/-/sparkles-1.0.1.tgz",
|
||||||
"integrity": "sha512-dSO0DDYUahUt/0/pD/Is3VIm5TGJjludZ0HVymmhYF6eNA53PVLhnUk0znSYbH8IYBuJdCE+1luR22jNLMaQdw=="
|
"integrity": "sha512-dSO0DDYUahUt/0/pD/Is3VIm5TGJjludZ0HVymmhYF6eNA53PVLhnUk0znSYbH8IYBuJdCE+1luR22jNLMaQdw=="
|
||||||
},
|
},
|
||||||
|
"sparse-bitfield": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
|
||||||
|
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"memory-pager": "^1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"spdx-correct": {
|
"spdx-correct": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz",
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
"method-override": "^3.0.0",
|
"method-override": "^3.0.0",
|
||||||
"moment": "^2.22.1",
|
"moment": "^2.22.1",
|
||||||
"moment-recur": "^1.0.7",
|
"moment-recur": "^1.0.7",
|
||||||
"mongoose": "^5.1.3",
|
"mongoose": "^5.3.4",
|
||||||
"morgan": "^1.7.0",
|
"morgan": "^1.7.0",
|
||||||
"nconf": "^0.10.0",
|
"nconf": "^0.10.0",
|
||||||
"node-gcm": "^1.0.2",
|
"node-gcm": "^1.0.2",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ module.exports = function baseModel (schema, options = {}) {
|
|||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: uuid,
|
default: uuid,
|
||||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ let schema = new Schema({
|
|||||||
todos: [{type: String, ref: 'Task'}],
|
todos: [{type: String, ref: 'Task'}],
|
||||||
rewards: [{type: String, ref: 'Task'}],
|
rewards: [{type: String, ref: 'Task'}],
|
||||||
},
|
},
|
||||||
leader: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.'], required: true},
|
leader: {type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true},
|
||||||
group: {type: String, ref: 'Group', validate: [validator.isUUID, 'Invalid uuid.'], required: true},
|
group: {type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true},
|
||||||
memberCount: {type: Number, default: 0},
|
memberCount: {type: Number, default: 0},
|
||||||
prize: {type: Number, default: 0, min: 0},
|
prize: {type: Number, default: 0, min: 0},
|
||||||
categories: [{
|
categories: [{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export let schema = new mongoose.Schema({
|
|||||||
required: true,
|
required: true,
|
||||||
trim: true,
|
trim: true,
|
||||||
lowercase: true,
|
lowercase: true,
|
||||||
validator: [validator.isEmail, 'Invalid email.'],
|
validator: [v => validator.isEmail(v), 'Invalid email.'],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
strict: true,
|
strict: true,
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export let schema = new Schema({
|
|||||||
name: {type: String, required: true},
|
name: {type: String, required: true},
|
||||||
summary: {type: String, maxlength: MAX_SUMMARY_SIZE_FOR_GUILDS},
|
summary: {type: String, maxlength: MAX_SUMMARY_SIZE_FOR_GUILDS},
|
||||||
description: String,
|
description: String,
|
||||||
leader: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.'], required: true},
|
leader: {type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true},
|
||||||
type: {type: String, enum: ['guild', 'party'], required: true},
|
type: {type: String, enum: ['guild', 'party'], required: true},
|
||||||
privacy: {type: String, enum: ['private', 'public'], default: 'private', required: true},
|
privacy: {type: String, enum: ['private', 'public'], default: 'private', required: true},
|
||||||
chat: Array, // Used for backward compatibility, but messages aren't stored here
|
chat: Array, // Used for backward compatibility, but messages aren't stored here
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const Schema = mongoose.Schema;
|
|||||||
export let schema = new Schema({
|
export let schema = new Schema({
|
||||||
_id: {type: String, required: true}, // Use a custom string as _id
|
_id: {type: String, required: true}, // Use a custom string as _id
|
||||||
consumed: {type: Boolean, default: false, required: true},
|
consumed: {type: Boolean, default: false, required: true},
|
||||||
userId: {type: String, ref: 'User', required: true, validate: [validator.isUUID, 'Invalid uuid.']},
|
userId: {type: String, ref: 'User', required: true, validate: [v => validator.isUUID(v), 'Invalid uuid.']},
|
||||||
}, {
|
}, {
|
||||||
strict: true,
|
strict: true,
|
||||||
minimize: false, // So empty objects are returned
|
minimize: false, // So empty objects are returned
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import validator from 'validator';
|
|||||||
export let schema = new mongoose.Schema({
|
export let schema = new mongoose.Schema({
|
||||||
planId: String,
|
planId: String,
|
||||||
subscriptionId: String,
|
subscriptionId: String,
|
||||||
owner: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']},
|
owner: {type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.']},
|
||||||
quantity: {type: Number, default: 1},
|
quantity: {type: Number, default: 1},
|
||||||
paymentMethod: String, // enum: ['Paypal', 'Stripe', 'Gift', 'Amazon Payments', 'Google', '']}
|
paymentMethod: String, // enum: ['Paypal', 'Stripe', 'Gift', 'Amazon Payments', 'Google', '']}
|
||||||
customerId: String, // Billing Agreement Id in case of Amazon Payments
|
customerId: String, // Billing Agreement Id in case of Amazon Payments
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export let schema = new Schema({
|
|||||||
id: {
|
id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: uuid,
|
default: uuid,
|
||||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
name: {type: String, required: true},
|
name: {type: String, required: true},
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export let TaskSchema = new Schema({
|
|||||||
},
|
},
|
||||||
tags: [{
|
tags: [{
|
||||||
type: String,
|
type: String,
|
||||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
||||||
}],
|
}],
|
||||||
value: {type: Number, default: 0, required: true}, // redness or cost for rewards Required because it must be settable (for rewards)
|
value: {type: Number, default: 0, required: true}, // redness or cost for rewards Required because it must be settable (for rewards)
|
||||||
priority: {
|
priority: {
|
||||||
@@ -89,26 +89,26 @@ export let TaskSchema = new Schema({
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
attribute: {type: String, default: 'str', enum: ['str', 'con', 'int', 'per']},
|
attribute: {type: String, default: 'str', enum: ['str', 'con', 'int', 'per']},
|
||||||
userId: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set it belongs to a challenge
|
userId: {type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.']}, // When not set it belongs to a challenge
|
||||||
|
|
||||||
challenge: {
|
challenge: {
|
||||||
shortName: {type: String},
|
shortName: {type: String},
|
||||||
id: {type: String, ref: 'Challenge', validate: [validator.isUUID, 'Invalid uuid.']}, // When set (and userId not set) it's the original task
|
id: {type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid.']}, // When set (and userId not set) it's the original task
|
||||||
taskId: {type: String, ref: 'Task', validate: [validator.isUUID, 'Invalid uuid.']}, // When not set but challenge.id defined it's the original task
|
taskId: {type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid.']}, // When not set but challenge.id defined it's the original task
|
||||||
broken: {type: String, enum: ['CHALLENGE_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED', 'CHALLENGE_CLOSED', 'CHALLENGE_TASK_NOT_FOUND']}, // CHALLENGE_TASK_NOT_FOUND comes from v3 migration
|
broken: {type: String, enum: ['CHALLENGE_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED', 'CHALLENGE_CLOSED', 'CHALLENGE_TASK_NOT_FOUND']}, // CHALLENGE_TASK_NOT_FOUND comes from v3 migration
|
||||||
winner: String, // user.profile.name of the winner
|
winner: String, // user.profile.name of the winner
|
||||||
},
|
},
|
||||||
|
|
||||||
group: {
|
group: {
|
||||||
id: {type: String, ref: 'Group', validate: [validator.isUUID, 'Invalid uuid.']},
|
id: {type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.']},
|
||||||
broken: {type: String, enum: ['GROUP_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED']},
|
broken: {type: String, enum: ['GROUP_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED']},
|
||||||
assignedUsers: [{type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']}],
|
assignedUsers: [{type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.']}],
|
||||||
taskId: {type: String, ref: 'Task', validate: [validator.isUUID, 'Invalid uuid.']},
|
taskId: {type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid.']},
|
||||||
approval: {
|
approval: {
|
||||||
required: {type: Boolean, default: false},
|
required: {type: Boolean, default: false},
|
||||||
approved: {type: Boolean, default: false},
|
approved: {type: Boolean, default: false},
|
||||||
dateApproved: {type: Date},
|
dateApproved: {type: Date},
|
||||||
approvingUser: {type: String, ref: 'User', validate: [validator.isUUID, 'Invalid uuid.']},
|
approvingUser: {type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.']},
|
||||||
requested: {type: Boolean, default: false},
|
requested: {type: Boolean, default: false},
|
||||||
requestedDate: {type: Date},
|
requestedDate: {type: Date},
|
||||||
},
|
},
|
||||||
@@ -117,7 +117,7 @@ export let TaskSchema = new Schema({
|
|||||||
|
|
||||||
reminders: [{
|
reminders: [{
|
||||||
_id: false,
|
_id: false,
|
||||||
id: {type: String, validate: [validator.isUUID, 'Invalid uuid.'], default: shared.uuid, required: true},
|
id: {type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true},
|
||||||
startDate: {type: Date},
|
startDate: {type: Date},
|
||||||
time: {type: Date, required: true},
|
time: {type: Date, required: true},
|
||||||
}],
|
}],
|
||||||
@@ -265,7 +265,7 @@ let dailyTodoSchema = () => {
|
|||||||
completed: {type: Boolean, default: false},
|
completed: {type: Boolean, default: false},
|
||||||
text: {type: String, required: false, default: ''}, // required:false because it can be empty on creation
|
text: {type: String, required: false, default: ''}, // required:false because it can be empty on creation
|
||||||
_id: false,
|
_id: false,
|
||||||
id: {type: String, default: shared.uuid, required: true, validate: [validator.isUUID, 'Invalid uuid.']},
|
id: {type: String, default: shared.uuid, required: true, validate: [v => validator.isUUID(v), 'Invalid uuid.']},
|
||||||
linkId: {type: String},
|
linkId: {type: String},
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ let schema = new Schema({
|
|||||||
email: {
|
email: {
|
||||||
type: String,
|
type: String,
|
||||||
validate: [{
|
validate: [{
|
||||||
validator: validator.isEmail,
|
validator: (v) => validator.isEmail(v),
|
||||||
message: shared.i18n.t('invalidEmail'),
|
message: shared.i18n.t('invalidEmail'),
|
||||||
}, {
|
}, {
|
||||||
validator (email) {
|
validator (email) {
|
||||||
@@ -374,7 +374,7 @@ let schema = new Schema({
|
|||||||
return {};
|
return {};
|
||||||
}},
|
}},
|
||||||
|
|
||||||
challenges: [{type: String, ref: 'Challenge', validate: [validator.isUUID, 'Invalid uuid.']}],
|
challenges: [{type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid.']}],
|
||||||
|
|
||||||
invitations: {
|
invitations: {
|
||||||
// Using an array without validation because otherwise mongoose treat this as a subdocument and applies _id by default
|
// Using an array without validation because otherwise mongoose treat this as a subdocument and applies _id by default
|
||||||
@@ -391,7 +391,7 @@ let schema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
ref: 'Group',
|
ref: 'Group',
|
||||||
required: true,
|
required: true,
|
||||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -401,15 +401,15 @@ let schema = new Schema({
|
|||||||
type: String,
|
type: String,
|
||||||
ref: 'User',
|
ref: 'User',
|
||||||
required: true,
|
required: true,
|
||||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
|
|
||||||
guilds: [{type: String, ref: 'Group', validate: [validator.isUUID, 'Invalid uuid.']}],
|
guilds: [{type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.']}],
|
||||||
|
|
||||||
party: {
|
party: {
|
||||||
_id: {type: String, validate: [validator.isUUID, 'Invalid uuid.'], ref: 'Group'},
|
_id: {type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], ref: 'Group'},
|
||||||
order: {type: String, default: 'level'},
|
order: {type: String, default: 'level'},
|
||||||
orderAscending: {type: String, default: 'ascending'},
|
orderAscending: {type: String, default: 'ascending'},
|
||||||
quest: {
|
quest: {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export let schema = new Schema({
|
|||||||
id: {
|
id: {
|
||||||
type: String,
|
type: String,
|
||||||
default: uuid,
|
default: uuid,
|
||||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
||||||
// @TODO: Add these back once we figure out the issue with notifications
|
// @TODO: Add these back once we figure out the issue with notifications
|
||||||
// See Fix for https://github.com/HabitRPG/habitica/issues/9923
|
// See Fix for https://github.com/HabitRPG/habitica/issues/9923
|
||||||
// required: true,
|
// required: true,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export let schema = new Schema({
|
|||||||
id: {
|
id: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
validate: [validator.isUUID, shared.i18n.t('invalidWebhookId')],
|
validate: [v => validator.isUUID(v), shared.i18n.t('invalidWebhookId')],
|
||||||
default: uuid,
|
default: uuid,
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
|
|||||||
Reference in New Issue
Block a user