Browse Source

Reduced limits on users

Owen Diffey 3 years ago
parent
commit
4147d1d3ba
2 changed files with 6 additions and 51 deletions
  1. 1 41
      backend/logic/actions/stations.js
  2. 5 10
      backend/logic/db/index.js

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

@@ -3049,48 +3049,8 @@ export default {
 				(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);
+					return next(null, song, station);
 				},
 
 				(song, next) => {

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

@@ -168,11 +168,11 @@ class _DBModule extends CoreClass {
 							new Promise((resolve, reject) => {
 								this.models.station.countDocuments({ owner }, (err, c) => {
 									if (err) reject(new Error("A mongo error happened."));
-									else if (c >= 3) reject(new Error("User already has 3 stations."));
+									else if (c >= 25) reject(new Error("User already has 25 stations."));
 									else resolve();
 								});
 							}),
-						message: "User already has 3 stations."
+						message: "User already has 25 stations."
 					});
 
 					/*
@@ -248,17 +248,12 @@ class _DBModule extends CoreClass {
 						);
 
 					this.schemas.playlist.path("createdBy").validate(createdBy => {
-						this.models.playlist.countDocuments({ createdBy }, (err, c) => !(err || c >= 10));
-					}, "Max 10 playlists per user.");
+						this.models.playlist.countDocuments({ createdBy }, (err, c) => !(err || c >= 100));
+					}, "Max 100 playlists per user.");
 
 					this.schemas.playlist
 						.path("songs")
-						.validate(songs => songs.length <= 5000, "Max 5000 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.");
+						.validate(songs => songs.length <= 10000, "Max 10000 songs per playlist.");
 
 					this.schemas.playlist.index({ createdFor: 1, type: 1 }, { unique: true });