Browse Source

refactor: trim certain user modifiable strings in playlists, songs, reports and stations

Owen Diffey 2 years ago
parent
commit
581d10776b

+ 1 - 1
backend/logic/db/schemas/playlist.js

@@ -1,7 +1,7 @@
 import mongoose from "mongoose";
 
 export default {
-	displayName: { type: String, min: 2, max: 32, required: true },
+	displayName: { type: String, min: 2, max: 32, trim: true, required: true },
 	songs: [
 		{
 			_id: { type: mongoose.Schema.Types.ObjectId, required: false },

+ 1 - 1
backend/logic/db/schemas/report.js

@@ -12,7 +12,7 @@ export default {
 				required: true
 			},
 			title: { type: String, required: true },
-			description: { type: String, required: false },
+			description: { type: String, trim: true, required: false },
 			resolved: { type: Boolean, default: false, required: true }
 		}
 	],

+ 5 - 5
backend/logic/db/schemas/song.js

@@ -1,12 +1,12 @@
 export default {
 	youtubeId: { type: String, min: 11, max: 11, required: true, index: true, unique: true },
-	title: { type: String, required: true },
-	artists: [{ type: String, default: [] }],
-	genres: [{ type: String, default: [] }],
-	tags: [{ type: String, default: [] }],
+	title: { type: String, trim: true, required: true },
+	artists: [{ type: String, trim: true, default: [] }],
+	genres: [{ type: String, trim: true, default: [] }],
+	tags: [{ type: String, trim: true, default: [] }],
 	duration: { type: Number, min: 1, required: true },
 	skipDuration: { type: Number, required: true, default: 0 },
-	thumbnail: { type: String },
+	thumbnail: { type: String, trim: true },
 	likes: { type: Number, default: 0, required: true },
 	dislikes: { type: Number, default: 0, required: true },
 	explicit: { type: Boolean },

+ 2 - 2
backend/logic/db/schemas/station.js

@@ -3,8 +3,8 @@ import mongoose from "mongoose";
 export default {
 	name: { type: String, lowercase: true, maxlength: 16, minlength: 2, index: true, unique: true, required: true },
 	type: { type: String, enum: ["official", "community"], required: true },
-	displayName: { type: String, minlength: 2, maxlength: 32, required: true, unique: true },
-	description: { type: String, minlength: 2, maxlength: 128, required: true },
+	displayName: { type: String, minlength: 2, maxlength: 32, trim: true, required: true, unique: true },
+	description: { type: String, minlength: 2, maxlength: 128, trim: true, required: true },
 	paused: { type: Boolean, default: false, required: true },
 	currentSong: {
 		_id: { type: String },