Browse Source

Added removed limits code as comments

Owen Diffey 3 years ago
parent
commit
97a614c69a
2 changed files with 52 additions and 1 deletions
  1. 47 1
      backend/logic/actions/stations.js
  2. 5 0
      backend/logic/db/index.js

+ 47 - 1
backend/logic/actions/stations.js

@@ -3050,9 +3050,55 @@ export default {
 					song.requestedBy = session.userId;
 					song.requestedAt = Date.now();
 					return next(null, song);
-					return next(null, song, station);
 				},
 
+				// (song, station, next) => {
+				// 	song.requestedBy = session.userId;
+				// 	song.requestedAt = Date.now();
+				// 	let totalDuration = 0;
+				// 	station.queue.forEach(song => {
+				// 		totalDuration += song.duration;
+				// 	});
+				// 	if (totalDuration >= 3600 * 3) return next("The max length of the queue is 3 hours.");
+				// 	return next(null, song, station);
+				// },
+
+				// (song, station, next) => {
+				// 	if (station.queue.length === 0) return next(null, song, station);
+				// 	let totalDuration = 0;
+				// 	const userId = station.queue[station.queue.length - 1].requestedBy;
+				// 	station.queue.forEach(song => {
+				// 		if (userId === song.requestedBy) {
+				// 			totalDuration += song.duration;
+				// 		}
+				// 	});
+
+				// 	if (totalDuration >= 900) return next("The max length of songs per user is 15 minutes.");
+				// 	return next(null, song, station);
+				// },
+
+				// (song, station, next) => {
+				// 	if (station.queue.length === 0) return next(null, song);
+				// 	let totalSongs = 0;
+				// 	const userId = station.queue[station.queue.length - 1].requestedBy;
+				// 	station.queue.forEach(song => {
+				// 		if (userId === song.requestedBy) {
+				// 			totalSongs += 1;
+				// 		}
+				// 	});
+
+				// 	if (totalSongs <= 2) return next(null, song);
+				// 	if (totalSongs > 3)
+				// 		return next("The max amount of songs per user is 3, and only 2 in a row is allowed.");
+				// 	if (
+				// 		station.queue[station.queue.length - 2].requestedBy !== userId ||
+				// 		station.queue[station.queue.length - 3] !== userId
+				// 	)
+				// 		return next("The max amount of songs per user is 3, and only 2 in a row is allowed.");
+
+				// 	return next(null, song);
+				// },
+
 				(song, next) => {
 					stationModel.updateOne(
 						{ _id: stationId },

+ 5 - 0
backend/logic/db/index.js

@@ -255,6 +255,11 @@ class _DBModule extends CoreClass {
 						.path("songs")
 						.validate(songs => songs.length <= 10000, "Max 10000 songs per playlist.");
 
+					// this.schemas.playlist.path("songs").validate(songs => {
+					// 	if (songs.length === 0) return true;
+					// 	return songs[0].duration <= 10800;
+					// }, "Max 3 hours per song.");
+
 					this.schemas.playlist.index({ createdFor: 1, type: 1 }, { unique: true });
 
 					if (config.get("skipDbDocumentsVersionCheck")) resolve();