Sfoglia il codice sorgente

Added community station id blacklist.

KrisVos130 8 anni fa
parent
commit
c015ae04da
1 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 5 3
      backend/logic/actions/stations.js

+ 5 - 3
backend/logic/actions/stations.js

@@ -411,6 +411,7 @@ module.exports = {
 
 	create: hooks.loginRequired((session, data, cb) => {
 		data._id = data._id.toLowerCase();
+		let blacklist = ["country", "edm", "musare", "hip-hop", "rap", "top-hits", "todays-hits", "old-school", "christmas", "about", "support", "staff", "help", "news", "terms", "privacy", "profile", "c", "community", "tos", "login", "register", "p", "official", "o", "trap", "faq", "team", "donate", "buy", "shop", "forums", "explore", "settings", "admin"];
 		async.waterfall([
 
 			(next) => {
@@ -425,7 +426,7 @@ module.exports = {
 				if (station) return next({ 'status': 'failure', 'message': 'A station with that name or display name already exists' });
 				const { _id, displayName, description, genres, playlist, type, blacklistedGenres } = data;
 				cache.hget('sessions', session.sessionId, (err, session) => {
-					if (type == 'official') {
+					if (type === 'official') {
 						db.models.user.findOne({_id: session.userId}, (err, user) => {
 							if (err) return next({ 'status': 'failure', 'message': 'Something went wrong when getting your user info.' });
 							if (!user) return next({ 'status': 'failure', 'message': 'User not found.' });
@@ -442,7 +443,8 @@ module.exports = {
 								currentSong: stations.defaultSong
 							}, next);
 						});
-					} else if (type == 'community') {
+					} else if (type === 'community') {
+						if (blacklist.indexOf(_id) !== -1) return next({ 'status': 'failure', 'message': 'That id is blacklisted. Please use a different id.' });
 						db.models.station.create({
 							_id,
 							displayName,
@@ -460,7 +462,7 @@ module.exports = {
 		], (err, station) => {
 			if (err) {
 				console.error(err);
-				return cb({ 'status': 'failure', 'message': 'Something went wrong'});
+				return cb({ 'status': 'failure', 'message': err.message});
 			} else {
 				cache.pub('station.create', data._id);
 				cb({ 'status': 'success', 'message': 'Successfully created station' });