mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
clarify all "Invalid uuid" messages by making each unique
This commit is contained in:
@@ -12,7 +12,7 @@ export default function baseModel (schema, options = {}) {
|
|||||||
_id: {
|
_id: {
|
||||||
$type: String,
|
$type: String,
|
||||||
default: uuid,
|
default: uuid,
|
||||||
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid in baseModel.'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ const schema = new Schema({
|
|||||||
rewards: [{ $type: String, ref: 'Task' }],
|
rewards: [{ $type: String, ref: 'Task' }],
|
||||||
},
|
},
|
||||||
leader: {
|
leader: {
|
||||||
$type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true,
|
$type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for challenge leader.'], required: true,
|
||||||
},
|
},
|
||||||
group: {
|
group: {
|
||||||
$type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true,
|
$type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid for challenge group.'], 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 },
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export const schema = new Schema({
|
|||||||
summary: { $type: String, maxlength: MAX_SUMMARY_SIZE_FOR_GUILDS },
|
summary: { $type: String, maxlength: MAX_SUMMARY_SIZE_FOR_GUILDS },
|
||||||
description: String,
|
description: String,
|
||||||
leader: {
|
leader: {
|
||||||
$type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'], required: true,
|
$type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for group leader.'], required: true,
|
||||||
},
|
},
|
||||||
type: { $type: String, enum: ['guild', 'party'], required: true },
|
type: { $type: String, enum: ['guild', 'party'], required: true },
|
||||||
privacy: {
|
privacy: {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export const 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: {
|
userId: {
|
||||||
$type: String, ref: 'User', required: true, validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
$type: String, ref: 'User', required: true, validate: [v => validator.isUUID(v), 'Invalid uuid for iapPurchaseReceipt.'],
|
||||||
},
|
},
|
||||||
}, {
|
}, {
|
||||||
strict: true,
|
strict: true,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import baseModel from '../libs/baseModel';
|
|||||||
export const schema = new mongoose.Schema({
|
export const schema = new mongoose.Schema({
|
||||||
planId: String,
|
planId: String,
|
||||||
subscriptionId: String,
|
subscriptionId: String,
|
||||||
owner: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'] },
|
owner: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for subscription owner.'] },
|
||||||
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 const schema = new Schema({
|
|||||||
id: {
|
id: {
|
||||||
$type: String,
|
$type: String,
|
||||||
default: uuid,
|
default: uuid,
|
||||||
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid for tag.'],
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
name: { $type: String, required: true },
|
name: { $type: String, required: true },
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export const taskIsGroupOrChallengeQuery = {
|
|||||||
const reminderSchema = new Schema({
|
const reminderSchema = new Schema({
|
||||||
_id: false,
|
_id: false,
|
||||||
id: {
|
id: {
|
||||||
$type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], default: shared.uuid, required: true,
|
$type: String, validate: [v => validator.isUUID(v), 'Invalid uuid for task reminder.'], default: shared.uuid, required: true,
|
||||||
},
|
},
|
||||||
startDate: { $type: Date },
|
startDate: { $type: Date },
|
||||||
time: { $type: Date, required: true },
|
time: { $type: Date, required: true },
|
||||||
@@ -93,7 +93,7 @@ export const TaskSchema = new Schema({
|
|||||||
},
|
},
|
||||||
tags: [{
|
tags: [{
|
||||||
$type: String,
|
$type: String,
|
||||||
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid for task tags.'],
|
||||||
}],
|
}],
|
||||||
// redness or cost for rewards Required because it must be settable (for rewards)
|
// redness or cost for rewards Required because it must be settable (for rewards)
|
||||||
value: { $type: Number, default: 0, required: true },
|
value: { $type: Number, default: 0, required: true },
|
||||||
@@ -107,27 +107,27 @@ export const 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: [v => validator.isUUID(v), 'Invalid uuid.'] }, // When not set it belongs to a challenge
|
userId: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for task owner.'] }, // When not set it belongs to a challenge
|
||||||
|
|
||||||
challenge: {
|
challenge: {
|
||||||
shortName: { $type: String },
|
shortName: { $type: String },
|
||||||
id: { $type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), '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 for task challenge.'] }, // When set (and userId not set) 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
|
taskId: { $type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid for task challenge task.'] }, // 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: [v => validator.isUUID(v), 'Invalid uuid.'] },
|
id: { $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid for task group.'] },
|
||||||
broken: { $type: String, enum: ['GROUP_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED'] },
|
broken: { $type: String, enum: ['GROUP_DELETED', 'TASK_DELETED', 'UNSUBSCRIBED'] },
|
||||||
assignedUsers: [{ $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }],
|
assignedUsers: [{ $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid for task group user.'] }],
|
||||||
assignedDate: { $type: Date },
|
assignedDate: { $type: Date },
|
||||||
taskId: { $type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid.'] },
|
taskId: { $type: String, ref: 'Task', validate: [v => validator.isUUID(v), 'Invalid uuid for task group task.'] },
|
||||||
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: [v => validator.isUUID(v), 'Invalid uuid.'] },
|
approvingUser: { $type: String, ref: 'User', validate: [v => validator.isUUID(v), 'Invalid uuid task group approvingUser.'] },
|
||||||
requested: { $type: Boolean, default: false },
|
requested: { $type: Boolean, default: false },
|
||||||
requestedDate: { $type: Date },
|
requestedDate: { $type: Date },
|
||||||
},
|
},
|
||||||
@@ -292,7 +292,7 @@ const dailyTodoSchema = () => ({
|
|||||||
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: {
|
id: {
|
||||||
$type: String, default: shared.uuid, required: true, validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
$type: String, default: shared.uuid, required: true, validate: [v => validator.isUUID(v), 'Invalid uuid for task checklist item.'],
|
||||||
},
|
},
|
||||||
linkId: { $type: String },
|
linkId: { $type: String },
|
||||||
}],
|
}],
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ export default new Schema({
|
|||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
|
|
||||||
challenges: [{ $type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }],
|
challenges: [{ $type: String, ref: 'Challenge', validate: [v => validator.isUUID(v), 'Invalid uuid for user challenges.'] }],
|
||||||
|
|
||||||
invitations: {
|
invitations: {
|
||||||
// Using an array without validation because otherwise mongoose
|
// Using an array without validation because otherwise mongoose
|
||||||
@@ -424,7 +424,7 @@ export default new Schema({
|
|||||||
$type: String,
|
$type: String,
|
||||||
ref: 'Group',
|
ref: 'Group',
|
||||||
required: true,
|
required: true,
|
||||||
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid for user invitation party id.'],
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
$type: String,
|
$type: String,
|
||||||
@@ -434,15 +434,15 @@ export default new Schema({
|
|||||||
$type: String,
|
$type: String,
|
||||||
ref: 'User',
|
ref: 'User',
|
||||||
required: true,
|
required: true,
|
||||||
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid for user invitation inviter id.'],
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
|
|
||||||
guilds: [{ $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid.'] }],
|
guilds: [{ $type: String, ref: 'Group', validate: [v => validator.isUUID(v), 'Invalid uuid for user guild.'] }],
|
||||||
|
|
||||||
party: {
|
party: {
|
||||||
_id: { $type: String, validate: [v => validator.isUUID(v), 'Invalid uuid.'], ref: 'Group' },
|
_id: { $type: String, validate: [v => validator.isUUID(v), 'Invalid uuid for user party.'], ref: 'Group' },
|
||||||
order: { $type: String, default: 'level' },
|
order: { $type: String, default: 'level' },
|
||||||
orderAscending: { $type: String, default: 'ascending' },
|
orderAscending: { $type: String, default: 'ascending' },
|
||||||
quest: {
|
quest: {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export const schema = new Schema({
|
|||||||
id: {
|
id: {
|
||||||
$type: String,
|
$type: String,
|
||||||
default: uuid,
|
default: uuid,
|
||||||
validate: [v => validator.isUUID(v), 'Invalid uuid.'],
|
validate: [v => validator.isUUID(v), 'Invalid uuid for userNotification.'],
|
||||||
// @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,
|
||||||
|
|||||||
Reference in New Issue
Block a user