Browse Source

Mass removal of debugging

theflametrooper 8 years ago
parent
commit
2edabbb522

+ 0 - 2
backend/logic/actions/songs.js

@@ -75,7 +75,6 @@ module.exports = {
 				newSong.acceptedBy = userId;
 				newSong.acceptedAt = Date.now();
 				if (!existingSong) newSong.save(err => {
-					console.log(err, 1);
 					if (err) console.error(err);
 					else cb({ status: 'success', message: 'Song has been moved from Queue' })
 				});
@@ -93,7 +92,6 @@ module.exports = {
 				if (!err) {
 					db.models.user.update({_id: userId}, {$push: {liked: songId}, $pull: {disliked: songId}}, err => {
 						if (!err) {
-							console.log(JSON.stringify({ songId, userId: userId }));
 							songs.updateSong(songId, (err, song) => {});
 							cache.pub('song.like', JSON.stringify({ songId, userId: session.userId, undisliked: (dislikes === -1) }));
 						} else db.models.song.update({ _id: songId }, { $inc: { likes: -1, dislikes: -dislikes } }, err => {

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

@@ -37,26 +37,19 @@ cache.sub('station.voteSkipSong', stationId => {
 
 cache.sub('station.create', stationId => {
 	stations.initializeStation(stationId, (err, station) => {
-		console.log("*************", err, station);
+		if (err) console.error(err);
 		//TODO Emit to admin station page
-
 		// TODO If community, check if on whitelist
-		console.log("*************", station.privacy);
 		if (station.privacy === 'public') utils.emitToRoom('home', "event:stations.created", station);
 		else {
 			let sockets = utils.getRoomSockets('home');
-			console.log("*************", sockets.length);
 			for (let socketId in sockets) {
 				let socket = sockets[socketId];
 				let session = sockets[socketId].session;
-				console.log("*************", session);
 				if (session.sessionId) {
 					cache.hget('sessions', session.sessionId, (err, session) => {
-						console.log("*************", err, session);
 						if (!err && session) {
-							console.log("*************");
 							db.models.user.findOne({_id: session.userId}, (err, user) => {
-								console.log("*************", err, user.role, station.type, station.owner, session.userId);
 								if (user.role === 'admin') socket.emit("event:stations.created", station);
 								else if (station.type === "community" && station.owner === session.userId) socket.emit("event:stations.created", station);
 							});
@@ -370,7 +363,6 @@ module.exports = {
 				if (station.paused) {
 					station.paused = false;
 					station.timePaused += (Date.now() - station.pausedAt);
-					console.log("&&&", station.timePaused, station.pausedAt, Date.now(), station.timePaused);
 					db.models.station.update({_id: stationId}, {$set: {paused: false}, $inc: {timePaused: Date.now() - station.pausedAt}}, () => {
 						stations.updateStation(stationId, (err, station) => {
 							cache.pub('station.resume', stationId);
@@ -388,7 +380,6 @@ module.exports = {
 
 	remove: hooks.ownerRequired((session, stationId, cb) => {
 		db.models.station.remove({ _id: stationId }, (err) => {
-			console.log(err, stationId);
 			if (err) return cb({status: 'failure', message: 'Something went wrong when deleting that station.'});
 			cache.hdel('stations', stationId, () => {
 				return cb({ status: 'success', message: 'Station successfully removed' });
@@ -481,7 +472,6 @@ module.exports = {
 					} else cont(song);
 					function cont(song) {
 						db.models.station.update({_id: stationId}, {$push: {queue: song}}, (err) => {
-							console.log(err);
 							if (err) return cb({'status': 'failure', 'message': 'Something went wrong.'});
 							stations.updateStation(stationId, (err, station) => {
 								if (err) return cb(err);

+ 0 - 1
backend/logic/actions/users.js

@@ -84,7 +84,6 @@ module.exports = {
 			// if it is, we check if a user with the requested username already exists
 			(response, body, next) => {
 				let json = JSON.parse(body);
-				console.log(response, body);
 				if (json.success !== true) return next('Response from recaptcha was not successful');
 				db.models.user.findOne({ username: new RegExp(`^${username}$`, 'i') }, next);
 			},

+ 0 - 1
backend/logic/notifications.js

@@ -40,7 +40,6 @@ const lib = {
 	 * @param {Function} cb - gets called when the notification has been scheduled
 	 */
 	schedule: (name, time, cb) => {
-		console.log(time);
 		pub.set(crypto.createHash('md5').update(`_notification:${name}_`).digest('hex'), '', 'PX', time, 'NX', cb);
 	},
 

+ 5 - 42
backend/logic/stations.js

@@ -43,14 +43,11 @@ module.exports = {
 	},
 
 	initializeStation: function(stationId, cb) {
-		console.log(112233, stationId, cb);
 		if (typeof cb !== 'function') cb = ()=>{};
 		let _this = this;
 		_this.getStation(stationId, (err, station) => {
 			if (!err) {
-				console.log("###");
 				if (station) {
-					console.log("###1");
 					let notification = notifications.subscribe(`stations.nextSong?id=${station._id}`, _this.skipStation(station._id), true);
 					if (!station.paused ) {
 						/*if (!station.startedAt) {
@@ -62,9 +59,7 @@ module.exports = {
 							let timeLeft = ((station.currentSong.duration * 1000) - (Date.now() - station.startedAt - station.timePaused));
 							if (isNaN(timeLeft)) timeLeft = -1;
 							if (station.currentSong.duration * 1000 < timeLeft || timeLeft < 0) {
-								console.log("Test");
 								this.skipStation(station._id)((err, station) => {
-									console.log(45, err, station);
 									cb(err, station);
 								});
 							} else {
@@ -73,7 +68,6 @@ module.exports = {
 							}
 						} else {
 							_this.skipStation(station._id)((err, station) => {
-								console.log(47, err, station);
 								cb(err, station);
 							});
 						}
@@ -101,7 +95,6 @@ module.exports = {
 									let found = false;
 									song.genres.forEach((songGenre) => {
 										if (station.blacklistedGenres.indexOf(songGenre) !== -1) found = true;
-										console.log(songGenre, station.blacklistedGenres, station.blacklistedGenres.indexOf(songGenre), found);
 									});
 									if (!found) {
 										songList.push(song._id);
@@ -110,9 +103,7 @@ module.exports = {
 							});
 						}
 						genresDone.push(genre);
-						if (genresDone.length === station.genres.length) {
-							next();
-						}
+						if (genresDone.length === station.genres.length) next();
 					});
 				});
 			},
@@ -147,14 +138,12 @@ module.exports = {
 
 			(station, next) => {
 				if (station) return next(true, station);
-
 				db.models.station.findOne({ _id: stationId }, next);
 			},
 
 			(station, next) => {
 				if (station) {
 					station = cache.schemas.station(station);
-					console.log(1234321, stationId);
 					cache.hset('stations', stationId, station);
 					next(true, station);
 				} else next('Station not found.');
@@ -162,7 +151,6 @@ module.exports = {
 
 		], (err, station) => {
 			if (err && err !== true) cb(err);
-
 			cb(null, station);
 		});
 	},
@@ -176,7 +164,6 @@ module.exports = {
 
 			(station, next) => {
 				if (!station) return next('Station not found.');
-				console.log(123444321, stationId);
 				cache.hset('stations', stationId, station, (err) => {
 					if (err) return next(err);
 					next(null, station);
@@ -185,7 +172,6 @@ module.exports = {
 
 		], (err, station) => {
 			if (err && err !== true) cb(err);
-
 			cb(null, station);
 		});
 	},
@@ -194,17 +180,12 @@ module.exports = {
 		let _this = this;
 		return (cb) => {
 			if (typeof cb !== 'function') cb = ()=>{};
-			console.log("###2");
-			console.log("NOTIFICATION!!!");
 			_this.getStation(stationId, (err, station) => {
-				console.log("###3");
 				if (station) {
-					console.log("###4");
 					// notify all the sockets on this station to go to the next song
 					async.waterfall([
 
 						(next) => {
-							console.log("###5");
 							if (station.type === "official") {
 								if (station.playlist.length > 0) {
 									function func() {
@@ -238,9 +219,7 @@ module.exports = {
 										} else {
 											db.models.station.update({_id: station._id}, {$set: {currentSongIndex: 0}}, (err) => {
 												_this.updateStation(station._id, (err, station) => {
-													console.log(12345678, err, station);
 													_this.calculateSongForStation(station, (err, newPlaylist) => {
-														console.log('New playlist: ', newPlaylist);
 														if (!err) {
 															songs.getSong(newPlaylist[0], (err, song) => {
 																let $set = {};
@@ -314,9 +293,7 @@ module.exports = {
 							} else {
 								if (station.partyMode === true) {
 									if (station.queue.length > 0) {
-										console.log("##");
 										db.models.station.update({_id: stationId}, {$pull: {queue: {songId: station.queue[0]._id}}}, (err) => {
-											console.log("##1", err);
 											if (err) return next(err);
 											let $set = {};
 											$set.currentSong = station.queue[0];
@@ -328,21 +305,16 @@ module.exports = {
 											next(null, $set);
 										});
 									} else {
-										console.log("##2");
 										next(null, {currentSong: null});
 									}
 								} else {
 									db.models.playlist.findOne({_id: station.privatePlaylist}, (err, playlist) => {
-										console.log(station.privatePlaylist, err, playlist);
 										if (err || !playlist) return next(null, {currentSong: null});
 										playlist = playlist.songs;
 										if (playlist.length > 0) {
 											let $set = {};
-											if (station.currentSongIndex < playlist.length - 1) {
-												$set.currentSongIndex = station.currentSongIndex + 1;
-											} else {
-												$set.currentSongIndex = 0;
-											}
+											if (station.currentSongIndex < playlist.length - 1) $set.currentSongIndex = station.currentSongIndex + 1;
+											else $set.currentSongIndex = 0;
 											songs.getSong(playlist[$set.currentSongIndex]._id, (err, song) => {
 												if (!err && song) {
 													$set.currentSong = {
@@ -369,23 +341,17 @@ module.exports = {
 												$set.timePaused = 0;
 												next(null, $set);
 											});
-										} else {
-											next(null, {currentSong: null});
-										}
+										} else next(null, {currentSong: null});
 									});
 								}
 							}
 						},
 
 						($set, next) => {
-							console.log("$set", $set);
 							db.models.station.update({_id: station._id}, {$set}, (err) => {
-								console.log("##2.5", err);
 								_this.updateStation(station._id, (err, station) => {
-									console.log("##2.6", err);
-									if (station.type === 'community' && station.partyMode === true) {
+									if (station.type === 'community' && station.partyMode === true)
 										cache.pub('station.queueUpdate', stationId);
-									}
 									next(null, station);
 								});
 							});
@@ -393,7 +359,6 @@ module.exports = {
 
 
 					], (err, station) => {
-						console.log("##3", err);
 						if (!err) {
 							if (station.currentSong !== null && station.currentSong._id !== undefined) {
 								station.currentSong.skipVotes = 0;
@@ -406,12 +371,10 @@ module.exports = {
 							});
 							if (station.currentSong !== null && station.currentSong._id !== undefined) {
 								utils.socketsJoinSongRoom(utils.getRoomSockets(`station.${station._id}`), `song.${station.currentSong._id}`);
-								console.log("NEXT SONG!!!", station.currentSong);
 								if (!station.paused) {
 									notifications.schedule(`stations.nextSong?id=${station._id}`, station.currentSong.duration * 1000);
 								}
 							} else {
-								console.log("22", !!(station.currentSong));
 								utils.socketsLeaveSongRooms(utils.getRoomSockets(`station.${station._id}`), `song.${station.currentSong._id}`);
 							}
 							cb(null, station);

+ 1 - 1
frontend/components/Admin/Stations.vue

@@ -114,7 +114,7 @@
 					genres,
 					blacklistedGenres,
 				}, result => {
-					console.log(result);
+					// Toast
 				});
 			},
 			removeStation: function (index) {

+ 3 - 10
frontend/components/Modals/Playlists/Edit.vue

@@ -159,24 +159,17 @@
 					if (res.status == 'success') _this.playlist = res.data; _this.playlist.oldId = res.data._id;
 				});
 				_this.socket.on('event:playlist.addSong', (data) => {
-					if (_this.playlist._id === data.playlistId) {
-						console.log("PUSH!");
-						_this.playlist.songs.push(data.song);
-					}
+					if (_this.playlist._id === data.playlistId) _this.playlist.songs.push(data.song);
 				});
 				_this.socket.on('event:playlist.removeSong', (data) => {
 					if (_this.playlist._id === data.playlistId) {
 						_this.playlist.songs.forEach((song, index) => {
-							if (song._id === data.songId) {
-								_this.playlist.songs.splice(index, 1);
-							}
+							if (song._id === data.songId) _this.playlist.songs.splice(index, 1);
 						});
 					}
 				});
 				_this.socket.on('event:playlist.updateDisplayName', (data) => {
-					if (_this.playlist._id === data.playlistId) {
-						_this.playlist.displayName = data.displayName;
-					}
+					if (_this.playlist._id === data.playlistId) _this.playlist.displayName = data.displayName;
 				});
 			});
 		},

+ 0 - 1
frontend/components/Sidebars/Playlist.vue

@@ -50,7 +50,6 @@
 			},
 			isNotSelected: function(id) {
 				let _this = this;
-				console.log(_this.$parent.station);
 				//TODO Also change this once it changes for a station
 				if (_this.$parent.station && _this.$parent.station.privatePlaylist === id) return false;
 				return true;

+ 15 - 55
frontend/components/Station/Station.vue

@@ -131,7 +131,6 @@
 			},
 			youtubeReady: function() {
 				let local = this;
-				console.log("@@5", local.currentSong._id);
 				if (!local.player) {
 					local.player = new YT.Player("player", {
 						height: 270,
@@ -141,13 +140,11 @@
 						playerVars: {controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0},
 						events: {
 							'onReady': function (event) {
-								console.log("@@6");
 								local.playerReady = true;
 								let volume = parseInt(localStorage.getItem("volume"));
 								volume = (typeof volume === "number") ? volume : 20;
 								local.player.setVolume(volume);
 								if (volume > 0) local.player.unMute();
-								console.log("@@7");
 								local.playVideo();
 							},
 							'onStateChange': function (event) {
@@ -175,9 +172,7 @@
 			},
 			playVideo: function() {
 				let local = this;
-				console.log("@@9");
 				if (local.playerReady) {
-					console.log("@@@1");
 					local.videoLoading = true;
 					local.player.loadVideoById(local.currentSong._id, local.getTimeElapsed() / 1000 + local.currentSong.skipDuration);
 
@@ -204,14 +199,12 @@
 				let currentTime = Date.now();
 
 				if (local.currentTime !== undefined && local.paused) {
-					console.log("123");
 					local.timePaused += (Date.now() - local.currentTime);
 					local.currentTime = undefined;
 				}
 
 				let duration = (Date.now() - local.startedAt - local.timePaused) / 1000;
 				let songDuration = local.currentSong.duration;
-				//console.log(duration, currentTime, local.startedAt, local.timePaused, local.startedAt - local.timePaused, Date.now() - local.startedAt - local.timePaused, Date.now() - local.startedAt);
 				if (songDuration <= duration) local.player.pauseVideo();
 				if ((!local.paused) && duration <= songDuration) local.timeElapsed = local.formatTime(duration);
 			},
@@ -243,68 +236,46 @@
 			skipStation: function () {
 				let _this = this;
 				_this.socket.emit('stations.forceSkip', _this.stationId, data => {
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					} else {
-						Toast.methods.addToast('Successfully skipped the station\'s current song.', 4000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
+					else Toast.methods.addToast('Successfully skipped the station\'s current song.', 4000);
 				});
 			},
 			voteSkipStation: function () {
 				let _this = this;
 				_this.socket.emit('stations.voteSkip', _this.stationId, data => {
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					} else {
-						Toast.methods.addToast('Successfully voted to skip the current song.', 4000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
+					else Toast.methods.addToast('Successfully voted to skip the current song.', 4000);
 				});
 			},
 			resumeStation: function () {
 				let _this = this;
 				_this.socket.emit('stations.resume', _this.stationId, data => {
-					console.log(data);
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					} else {
-						Toast.methods.addToast('Successfully resumed the station.', 4000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
+					else Toast.methods.addToast('Successfully resumed the station.', 4000);
 				});
 			},
 			pauseStation: function () {
 				let _this = this;
 				_this.socket.emit('stations.pause', _this.stationId, data => {
-					console.log(data);
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					} else {
-						Toast.methods.addToast('Successfully paused the station.', 4000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
+					else Toast.methods.addToast('Successfully paused the station.', 4000);
 				});
 			},
 			toggleLike: function() {
 				let _this = this;
 				if (_this.liked) _this.socket.emit('songs.unlike', _this.currentSong._id, data => {
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
 				}); else _this.socket.emit('songs.like', _this.currentSong._id, data => {
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
 				});
 			},
 			toggleDislike: function() {
 				let _this = this;
 				if (_this.disliked) return _this.socket.emit('songs.undislike', _this.currentSong._id, data => {
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
 				});
 				_this.socket.emit('songs.dislike', _this.currentSong._id, data => {
-					if (data.status !== 'success') {
-						Toast.methods.addToast(`Error: ${data.message}`, 8000);
-					}
+					if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
 				});
 			},
 			joinStation: function () {
@@ -330,7 +301,6 @@
 							if (_this.simpleSong) {
 								_this.currentSong.skipDuration = 0;
 							}
-							console.log(12334);
 							_this.youtubeReady();
 							_this.playVideo();
 							_this.socket.emit('songs.getOwnSongRatings', res.data.currentSong._id, data => {
@@ -341,15 +311,11 @@
 							});
 						} else {
 							if (_this.playerReady) _this.player.pauseVideo();
-							console.log("NO SONG TRUE1", res.data);
 							_this.noSong = true;
 						}
 						if (_this.type === 'community') {
 							_this.socket.emit('stations.getQueue', _this.stationId, data => {
-								console.log(data);
-								if (data.status === 'success') {
-									_this.queue = data.queue;
-								}
+								if (data.status === 'success') _this.queue = data.queue;
 							});
 						}
 					} else {
@@ -387,7 +353,6 @@
 						if (_this.simpleSong) {
 							_this.currentSong.skipDuration = 0;
 						}
-						console.log(1233, _this.stationId);
 						if (!_this.playerReady) _this.youtubeReady();
 						else _this.playVideo();
 						_this.socket.emit('songs.getOwnSongRatings', data.currentSong._id, (data) => {
@@ -398,7 +363,6 @@
 						});
 					} else {
 						if (_this.playerReady) _this.player.pauseVideo();
-						console.log("NO SONG TRUE2", data);
 						_this.noSong = true;
 					}
 				});
@@ -452,15 +416,11 @@
 				});
 
 				_this.socket.on('event:queue.update', queue => {
-					if (this.type === 'community') {
-						this.queue = queue;
-					}
+					if (this.type === 'community') this.queue = queue;
 				});
 
 				_this.socket.on('event:song.voteSkipSong', () => {
-					if (this.currentSong) {
-						this.currentSong.skipVotes++;
-					}
+					if (this.currentSong) this.currentSong.skipVotes++;
 				});
 			});
 

+ 0 - 3
frontend/components/pages/Home.vue

@@ -87,7 +87,6 @@
 						_this.init();
 					});
 					_this.socket.on('event:stations.created', station => {
-						console.log("CREATED!!!", station);
 						if (!station.currentSong) station.currentSong = {thumbnail: '/assets/notes.png'};
 						if (station.privacy !== 'public') {
 							station.class = {'station-red': true}
@@ -113,9 +112,7 @@
 						_this.stations.official = [];
 						if (data.status === "success")  data.stations.forEach(station => {
 							if (!station.currentSong) station.currentSong = {thumbnail: '/assets/notes.png'};
-							console.log(station.privacy);
 							if (station.privacy !== 'public') {
-								console.log(123);
 								station.class = {'station-red': true}
 							} else if (station.type === 'community') {
 								if (station.owner === userId) {

+ 4 - 7
frontend/io.js

@@ -13,19 +13,19 @@ export default {
 		else callbacks.push(cb);
 	},
 
-	onConnect: function(cb) {
+	onConnect: (cb) => {
 		onConnectCallbacks.push(cb);
 	},
 
-	onDisconnect: function(cb) {
+	onDisconnect: (cb) => {
 		onDisconnectCallbacks.push(cb);
 	},
 
-	onConnectError: function(cb) {
+	onConnectError: (cb) => {
 		onConnectErrorCallbacks.push(cb);
 	},
 
-	removeAllListeners: function() {
+	removeAllListeners: function () {
 		Object.keys(this.socket._callbacks).forEach((id) => {
 			if (id.indexOf("$event:song") !== -1) {
 				delete this.socket._callbacks[id];
@@ -37,21 +37,18 @@ export default {
 		this.socket = window.socket = io(url);
 		this.socket.on('connect', () => {
 			// Connect
-			console.log("SOCKET.IO CONNECTED");
 			onConnectCallbacks.forEach((cb) => {
 				cb();
 			});
 		});
 		this.socket.on('disconnect', () => {
 			// Disconnect
-			console.log("SOCKET.IO DISCONNECTED");
 			onDisconnectCallbacks.forEach((cb) => {
 				cb();
 			});
 		});
 		this.socket.on('connect_error', () => {
 			// Connect error
-			console.log("SOCKET.IO ERROR WHILE CONNECTING");
 			onConnectErrorCallbacks.forEach((cb) => {
 				cb();
 			});