Browse Source

Made quite a bit of progress on changing song id's.

KrisVos130 8 years ago
parent
commit
650b15b106

+ 3 - 4
backend/logic/actions/playlists.js

@@ -193,7 +193,6 @@ let lib = {
 				return cb({ status: 'failure', message: err});
 			}
 			logger.success("PLAYLIST_GET", `Successfully got private playlist "${playlistId}" for user "${userId}".`);
-			console.log(playlist);
 			cb({
 				status: 'success',
 				data: playlist
@@ -250,7 +249,7 @@ let lib = {
 					if (err || !playlist || playlist.createdBy !== userId) return next('Something went wrong when trying to get the playlist');
 
 					async.each(playlist.songs, (song, next) => {
-						if (song._id === songId) return next('That song is already in the playlist');
+						if (song.songId === songId) return next('That song is already in the playlist');
 						next();
 					}, next);
 				});
@@ -263,7 +262,8 @@ let lib = {
 						});
 					} else {
 						next(null, {
-							_id: songId,
+							_id: song._id,
+							songId: songId,
 							title: song.title,
 							duration: song.duration
 						});
@@ -361,7 +361,6 @@ let lib = {
 
 			(playlist, next) => {
 				if (!playlist || playlist.createdBy !== userId) return next('Playlist not found');
-				console.log(playlist, playlistId, songId);
 				db.models.playlist.update({_id: playlistId}, {$pull: {songs: {_id: songId}}}, next);
 			},
 

+ 10 - 9
backend/logic/actions/queueSongs.js

@@ -11,7 +11,7 @@ const request = require('request');
 const hooks = require('./hooks');
 
 cache.sub('queue.newSong', songId => {
-	db.models.queueSong.findOne({_id: songId}, (err, song) => {
+	db.models.queueSong.findOne({songId}, (err, song) => {
 		utils.emitToRoom('admin.queue', 'event:admin.queueSong.added', song);
 	});
 });
@@ -21,7 +21,7 @@ cache.sub('queue.removedSong', songId => {
 });
 
 cache.sub('queue.update', songId => {
-	db.models.queueSong.findOne({_id: songId}, (err, song) => {
+	db.models.queueSong.findOne({songId}, (err, song) => {
 		utils.emitToRoom('admin.queue', 'event:admin.queueSong.updated', song);
 	});
 });
@@ -82,7 +82,7 @@ module.exports = {
 	update: hooks.adminRequired((session, songId, updatedSong, cb, userId) => {
 		async.waterfall([
 			(next) => {
-				db.models.queueSong.findOne({ _id: songId }, next);
+				db.models.queueSong.findOne({songId}, next);
 			},
 
 			(song, next) => {
@@ -91,7 +91,7 @@ module.exports = {
 				let $set = {};
 				for (let prop in updatedSong) if (updatedSong[prop] !== song[prop]) $set[prop] = updatedSong[prop]; updated = true;
 				if (!updated) return next('No properties changed');
-				db.models.queueSong.update({ _id: songId }, {$set}, next);
+				db.models.queueSong.update({songId}, {$set}, next);
 			}
 		], (err) => {
 			if (err) {
@@ -116,7 +116,7 @@ module.exports = {
 	remove: hooks.adminRequired((session, songId, cb, userId) => {
 		async.waterfall([
 			(next) => {
-				db.models.queueSong.remove({ _id: songId }, next);
+				db.models.queueSong.remove({_id: songId}, next);
 			}
 		], (err) => {
 			if (err) {
@@ -143,18 +143,19 @@ module.exports = {
 
 		async.waterfall([
 			(next) => {
-				db.models.queueSong.findOne({_id: songId}, next);
+				db.models.queueSong.findOne({songId}, next);
 			},
 
 			(song, next) => {
 				if (song) return next('This song is already in the queue.');
-				db.models.song.findOne({_id: songId}, next);
+				db.models.song.findOne({songId}, next);
 			},
 
 			// Get YouTube data from id
 			(song, next) => {
 				if (song) return next('This song has already been added.');
 				//TODO Add err object as first param of callback
+				console.log(52, songId);
 				utils.getSongFromYouTube(songId, (song) => {
 					song.artists = [];
 					song.genres = [];
@@ -174,9 +175,9 @@ module.exports = {
 			},
 			(newSong, next) => {
 				const song = new db.models.queueSong(newSong);
-				song.save(err => {
+				song.save((err, song) => {
 					if (err) return next(err);
-					next(null, newSong);
+					next(null, song);
 				});
 			},
 			(newSong, next) => {

+ 13 - 13
backend/logic/actions/songs.js

@@ -15,13 +15,13 @@ cache.sub('song.removed', songId => {
 });
 
 cache.sub('song.added', songId => {
-	db.models.song.findOne({_id: songId}, (err, song) => {
+	db.models.song.findOne({songId}, (err, song) => {
 		utils.emitToRoom('admin.songs', 'event:admin.song.added', song);
 	});
 });
 
 cache.sub('song.updated', songId => {
-	db.models.song.findOne({_id: songId}, (err, song) => {
+	db.models.song.findOne({songId}, (err, song) => {
 		utils.emitToRoom('admin.songs', 'event:admin.song.updated', song);
 	});
 });
@@ -120,7 +120,7 @@ module.exports = {
 	update: hooks.adminRequired((session, songId, song, cb) => {
 		async.waterfall([
 			(next) => {
-				db.models.song.update({_id: songId}, song, {upsert: true}, next);
+				db.models.song.update({_id: songId}, song, next);
 			},
 
 			(res, next) => {
@@ -133,7 +133,7 @@ module.exports = {
 				return cb({'status': 'failure', 'message': err});
 			}
 			logger.success("SONGS_UPDATE", `Successfully updated song "${songId}".`);
-			cache.pub('song.updated', song._id);
+			cache.pub('song.updated', song.songId);
 			cb({ status: 'success', message: 'Song has been successfully updated', data: song });
 		});
 	}),
@@ -148,7 +148,7 @@ module.exports = {
 	remove: hooks.adminRequired((session, songId, cb) => {
 		async.waterfall([
 			(next) => {
-				db.models.song.remove({_id: songId}, next);
+				db.models.song.remove({songId}, next);
 			},
 
 			(res, next) => {//TODO Check if res gets returned from above
@@ -177,13 +177,13 @@ module.exports = {
 	add: hooks.adminRequired((session, song, cb, userId) => {
 		async.waterfall([
 			(next) => {
-				queueSongs.remove(session, song._id, () => {
+				queueSongs.remove(session, song.songId, () => {
 					next();
 				});
 			},
 
 			(next) => {
-				db.models.song.findOne({_id: song._id}, next);
+				db.models.song.findOne({songId: song.songId}, next);
 			},
 
 			(existingSong, next) => {
@@ -203,8 +203,8 @@ module.exports = {
 				logger.error("SONGS_ADD", `User "${userId}" failed to add song. "${err}"`);
 				return cb({'status': 'failure', 'message': err});
 			}
-			logger.success("SONGS_ADD", `User "${userId}" successfully added song "${song._id}".`);
-			cache.pub('song.added', song._id);
+			logger.success("SONGS_ADD", `User "${userId}" successfully added song "${song.songId}".`);
+			cache.pub('song.added', song.songId);
 			cb({status: 'success', message: 'Song has been moved from the queue successfully.'});
 		});
 		//TODO Check if video is in queue and Add the song to the appropriate stations
@@ -227,7 +227,7 @@ module.exports = {
 						if (err) return cb({ status: 'failure', message: 'Something went wrong while liking this song.' });
 						db.models.user.count({"disliked": songId}, (err, dislikes) => {
 							if (err) return cb({ status: 'failure', message: 'Something went wrong while liking this song.' });
-							db.models.song.update({_id: songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
+							db.models.song.update({songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
 								if (err) return cb({ status: 'failure', message: 'Something went wrong while liking this song.' });
 								songs.updateSong(songId, (err, song) => {});
 								cache.pub('song.like', JSON.stringify({ songId, userId: session.userId, likes: likes, dislikes: dislikes }));
@@ -257,7 +257,7 @@ module.exports = {
 						if (err) return cb({ status: 'failure', message: 'Something went wrong while disliking this song.' });
 						db.models.user.count({"disliked": songId}, (err, dislikes) => {
 							if (err) return cb({ status: 'failure', message: 'Something went wrong while disliking this song.' });
-							db.models.song.update({_id: songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
+							db.models.song.update({songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
 								if (err) return cb({ status: 'failure', message: 'Something went wrong while disliking this song.' });
 								songs.updateSong(songId, (err, song) => {});
 								cache.pub('song.dislike', JSON.stringify({ songId, userId: session.userId, likes: likes, dislikes: dislikes }));
@@ -287,7 +287,7 @@ module.exports = {
 						if (err) return cb({ status: 'failure', message: 'Something went wrong while undisliking this song.' });
 						db.models.user.count({"disliked": songId}, (err, dislikes) => {
 							if (err) return cb({ status: 'failure', message: 'Something went wrong while undisliking this song.' });
-							db.models.song.update({_id: songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
+							db.models.song.update({songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
 								if (err) return cb({ status: 'failure', message: 'Something went wrong while undisliking this song.' });
 								songs.updateSong(songId, (err, song) => {});
 								cache.pub('song.undislike', JSON.stringify({ songId, userId: session.userId, likes: likes, dislikes: dislikes }));
@@ -317,7 +317,7 @@ module.exports = {
 						if (err) return cb({ status: 'failure', message: 'Something went wrong while unliking this song.' });
 						db.models.user.count({"disliked": songId}, (err, dislikes) => {
 							if (err) return cb({ status: 'failure', message: 'Something went wrong while undiking this song.' });
-							db.models.song.update({_id: songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
+							db.models.song.update({songId}, {$set: {likes: likes, dislikes: dislikes}}, (err) => {
 								if (err) return cb({ status: 'failure', message: 'Something went wrong while unliking this song.' });
 								songs.updateSong(songId, (err, song) => {});
 								cache.pub('song.unlike', JSON.stringify({ songId, userId: session.userId, likes: likes, dislikes: dislikes }));

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

@@ -262,9 +262,9 @@ module.exports = {
 
 			(data, next) => {
 				if (!data.currentSong) return next(null, data);
-				utils.socketJoinSongRoom(session.socketId, `song.${data.currentSong._id}`);
+				utils.socketJoinSongRoom(session.socketId, `song.${data.currentSong.songId}`);
 				data.currentSong.skipVotes = data.currentSong.skipVotes.length;
-				songs.getSong(data.currentSong._id, (err, song) => {
+				songs.getSong(data.currentSong.songId, (err, song) => {
 					if (!err && song) {
 						data.currentSong.likes = song.likes;
 						data.currentSong.dislikes = song.dislikes;
@@ -699,9 +699,9 @@ module.exports = {
 			(station, next) => {
 				if (!station) return next('Station not found.');
 				if (station.type !== 'community') return next('That station is not a community station.');
-				if (station.currentSong && station.currentSong._id === songId) return next('That song is currently playing.');
+				if (station.currentSong && station.currentSong.songId === songId) return next('That song is currently playing.');
 				async.each(station.queue, (queueSong, next) => {
-					if (queueSong._id === songId) return next('That song is already in the queue.');
+					if (queueSong.songId === songId) return next('That song is already in the queue.');
 					next();
 				}, (err) => {
 					next(err, station);
@@ -711,6 +711,7 @@ module.exports = {
 			(station, next) => {
 				songs.getSong(songId, (err, song) => {
 					if (!err && song) return next(null, song);
+					console.log(53, songId);
 					utils.getSongFromYouTube(songId, (song) => {
 						song.artists = [];
 						song.skipDuration = 0;
@@ -763,7 +764,7 @@ module.exports = {
 				if (!station) return next('Station not found.');
 				if (station.type !== 'community') return next('Station is not a community station.');
 				async.each(station.queue, (queueSong, next) => {
-					if (queueSong._id === songId) return next(true);
+					if (queueSong.songId === songId) return next(true);
 					next();
 				}, (err) => {
 					if (err === true) return next();

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

@@ -1,5 +1,5 @@
 module.exports = {
-	_id: { type: String, unique: true, required: true },
+	songId: { type: String, min: 11, max: 11, required: true, index: true },
 	title: { type: String, required: true },
 	artists: [{ type: String }],
 	genres: [{ type: String }],

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

@@ -1,5 +1,5 @@
 module.exports = {
-	_id: { type: String, unique: true, required: true },
+	songId: { type: String, min: 11, max: 11, required: true, index: true },
 	title: { type: String, required: true },
 	artists: [{ type: String }],
 	genres: [{ type: String }],

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

@@ -5,7 +5,7 @@ module.exports = {
 	description: { type: String, minlength: 2, maxlength: 128, required: true },
 	paused: { type: Boolean, default: false, required: true },
 	currentSong: {
-		_id: { type: String },
+		songId: { type: String },
 		title: { type: String },
 		artists: [{ type: String }],
 		duration: { type: Number },
@@ -25,7 +25,7 @@ module.exports = {
 	privacy: { type: String, enum: ["public", "unlisted", "private"], default: "private" },
 	locked: { type: Boolean, default: false },
 	queue: [{
-		_id: { type: String, required: true },
+		songId: { type: String, required: true },
 		title: { type: String },
 		artists: [{ type: String }],
 		duration: { type: Number },

+ 27 - 6
backend/logic/songs.js

@@ -5,6 +5,7 @@ const db = require('./db');
 const io = require('./io');
 const utils = require('./utils');
 const async = require('async');
+const mongoose = require('mongoose');
 
 module.exports = {
 
@@ -23,7 +24,7 @@ module.exports = {
 				if (!songs) return next();
 				let songIds = Object.keys(songs);
 				async.each(songIds, (songId, next) => {
-					db.models.song.findOne({ _id: songId }, (err, song) => {
+					db.models.song.findOne({songId}, (err, song) => {
 						if (err) next(err);
 						else if (!song) cache.hdel('songs', songId, next);
 						else next();
@@ -37,7 +38,7 @@ module.exports = {
 
 			(songs, next) => {
 				async.each(songs, (song, next) => {
-					cache.hset('songs', song._id, cache.schemas.song(song), next);
+					cache.hset('songs', song.songId, cache.schemas.song(song), next);
 				}, next);
 			}
 		], (err) => {
@@ -58,13 +59,13 @@ module.exports = {
 		async.waterfall([
 
 			(next) => {
+				if (!mongoose.Types.ObjectId.isValid(songId)) return next('Id is not a valid ObjectId.');
 				cache.hget('songs', songId, next);
 			},
 
 			(song, next) => {
 				if (song) return next(true, song);
-
-				db.models.song.findOne({ _id: songId }, next);
+				db.models.song.findOne({_id: songId}, next);
 			},
 
 			(song, next) => {
@@ -80,6 +81,26 @@ module.exports = {
 		});
 	},
 
+	/**
+	 * Gets a song by song id from the cache or Mongo, and if it isn't in the cache yet, adds it the cache
+	 *
+	 * @param {String} songId - the id of the song we are trying to get
+	 * @param {Function} cb - gets called once we're done initializing
+	 */
+	getSongFromId: function(songId, cb) {
+		async.waterfall([
+
+			(next) => {
+				db.models.song.findOne({songId}, next);
+			}
+
+		], (err, song) => {
+			if (err && err !== true) return cb(err);
+
+			cb(null, song);
+		});
+	},
+
 	/**
 	 * Gets a song from id from Mongo and updates the cache with it
 	 *
@@ -90,7 +111,7 @@ module.exports = {
 		async.waterfall([
 
 			(next) => {
-				db.models.song.findOne({ _id: songId }, next);
+				db.models.song.findOne({_id: songId}, next);
 			},
 
 			(song, next) => {
@@ -119,7 +140,7 @@ module.exports = {
 		async.waterfall([
 
 			(next) => {
-				db.models.song.remove({ _id: songId }, next);
+				db.models.song.remove({ songId }, next);
 			},
 
 			(next) => {

+ 16 - 14
backend/logic/stations.js

@@ -133,13 +133,13 @@ module.exports = {
 					db.models.song.find({genres: genre}, (err, songs) => {
 						if (!err) {
 							songs.forEach((song) => {
-								if (songList.indexOf(song._id) === -1) {
+								if (songList.indexOf(song.songId) === -1) {
 									let found = false;
 									song.genres.forEach((songGenre) => {
 										if (station.blacklistedGenres.indexOf(songGenre) !== -1) found = true;
 									});
 									if (!found) {
-										songList.push(song._id);
+										songList.push(song.songId);
 									}
 								}
 							});
@@ -236,10 +236,10 @@ module.exports = {
 		let lessInfoPlaylist = [];
 
 		async.each(songList, (song, next) => {
-			songs.getSong(song, (err, song) => {
+			songs.getSongFromId(song, (err, song) => {
 				if (!err && song) {
 					let newSong = {
-						_id: song._id,
+						songId: song.songId,
 						title: song.title,
 						artists: song.artists,
 						duration: song.duration
@@ -284,13 +284,13 @@ module.exports = {
 								let currentSongIndex;
 								if (station.currentSongIndex < playlist.length - 1) currentSongIndex = station.currentSongIndex + 1;
 								else currentSongIndex = 0;
-								songs.getSong(playlist[currentSongIndex]._id, (err, song) => {
+								let callback = (err, song) => {
 									if (err) return next(err);
 									if (song) return next(null, song, currentSongIndex, station);
 									else {
 										let song = playlist[currentSongIndex];
 										let currentSong = {
-											_id: song._id,
+											songId: song.songId,
 											title: song.title,
 											duration: song.duration,
 											likes: -1,
@@ -298,7 +298,9 @@ module.exports = {
 										};
 										return next(null, currentSong, currentSongIndex, station);
 									}
-								});
+								};
+								if (playlist[currentSongIndex]._id) songs.getSong(playlist[currentSongIndex]._id, callback);
+								else songs.getSongFromId(playlist[currentSongIndex].songId, callback);
 							} else return next(null, null, -14, station);
 						});
 					}
@@ -327,7 +329,7 @@ module.exports = {
 							} else {
 								_this.calculateSongForStation(station, (err, newPlaylist) => {
 									if (err) return next(null, _this.defaultSong, 0);
-									songs.getSong(newPlaylist[0], (err, song) => {
+									songs.getSongFromId(newPlaylist[0], (err, song) => {
 										if (err || !song) return next(null, _this.defaultSong, 0);
 										station.playlist = newPlaylist;
 										next(null, song, 0);
@@ -346,7 +348,7 @@ module.exports = {
 					if (song === null) $set.currentSong = null;
 					else if (song.likes === -1 && song.dislikes === -1) {
 						$set.currentSong = {
-							_id: song._id,
+							songId: song.songId,
 							title: song.title,
 							duration: song.duration,
 							likes: -1,
@@ -354,7 +356,7 @@ module.exports = {
 						};
 					} else {
 						$set.currentSong = {
-							_id: song._id,
+							songId: song.songId,
 							title: song.title,
 							artists: song.artists,
 							duration: song.duration,
@@ -382,7 +384,7 @@ module.exports = {
 				},
 			], (err, station) => {
 				if (!err) {
-					if (station.currentSong !== null && station.currentSong._id !== undefined) {
+					if (station.currentSong !== null && station.currentSong.songId !== undefined) {
 						station.currentSong.skipVotes = 0;
 					}
 					//TODO Pub/Sub this
@@ -413,8 +415,8 @@ module.exports = {
 							}
 						}
 					}
-					if (station.currentSong !== null && station.currentSong._id !== undefined) {
-						utils.socketsJoinSongRoom(utils.getRoomSockets(`station.${station._id}`), `song.${station.currentSong._id}`);
+					if (station.currentSong !== null && station.currentSong.songId !== undefined) {
+						utils.socketsJoinSongRoom(utils.getRoomSockets(`station.${station._id}`), `song.${station.currentSong.songId}`);
 						if (!station.paused) {
 							notifications.schedule(`stations.nextSong?id=${station._id}`, station.currentSong.duration * 1000);
 						}
@@ -432,7 +434,7 @@ module.exports = {
 	},
 
 	defaultSong: {
-		_id: '60ItHLz5WEA',
+		songId: '60ItHLz5WEA',
 		title: 'Faded - Alan Walker',
 		duration: 212,
 		likes: -1,

+ 1 - 1
backend/logic/utils.js

@@ -268,7 +268,7 @@ module.exports = {
 				});
 
 				let song = {
-					_id: body.items[0].id,
+					songId: body.items[0].id,
 					title: body.items[0].snippet.title,
 					duration
 				};

+ 2 - 1
frontend/components/Admin/QueueSongs.vue

@@ -22,7 +22,7 @@
 					<td>
 						<strong>{{ song.title }}</strong>
 					</td>
-					<td>{{ song._id }}</td>
+					<td>{{ song.songId }}</td>
 					<td>{{ song.artists.join(', ') }}</td>
 					<td>{{ song.genres.join(', ') }}</td>
 					<td>{{ song.requestedBy }}</td>
@@ -89,6 +89,7 @@
 				});
 			},
 			remove: function (id, index) {
+				console.log("Removing ", id);
 				this.socket.emit('queueSongs.remove', id, res => {
 					if (res.status == 'success') Toast.methods.addToast(res.message, 2000);
 				});

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

@@ -22,7 +22,7 @@
 					<td>
 						<strong>{{ song.title }}</strong>
 					</td>
-					<td>{{ song._id }}</td>
+					<td>{{ song.songId }}</td>
 					<td>{{ song.artists.join(', ') }}</td>
 					<td>{{ song.genres.join(', ') }}</td>
 					<td>{{ song.requestedBy }}</td>

+ 3 - 3
frontend/components/Modals/EditSong.vue

@@ -56,7 +56,7 @@
 				<div class="control is-horizontal">
 					<div class="control is-grouped">
 						<p class='control is-expanded'>
-							<input class='input' type='text' v-model='editing.song._id'>
+							<input class='input' type='text' v-model='editing.song.songId'>
 						</p>
 						<p class='control is-expanded'>
 							<input class='input' type='text' v-model='editing.song.title' autofocus>
@@ -263,7 +263,7 @@
 			this.video.player = new YT.Player('player', {
 				height: 315,
 				width: 560,
-				videoId: this.editing.song._id,
+				videoId: this.editing.song.songId,
 				playerVars: { controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0 },
 				startSeconds: _this.editing.song.skipDuration,
 				events: {
@@ -312,7 +312,7 @@
 			},
 			editSong: function (song, index, type) {
 				let _this = this;
-				this.video.player.loadVideoById(song._id, this.editing.song.skipDuration);
+				this.video.player.loadVideoById(song.songId, this.editing.song.skipDuration);
 				let newSong = {};
 				for (let n in song) {
 					newSong[n] = song[n];

+ 6 - 5
frontend/components/Station/Station.vue

@@ -158,7 +158,7 @@
 					local.player = new YT.Player("player", {
 						height: 270,
 						width: 480,
-						videoId: local.currentSong._id,
+						videoId: local.currentSong.songId,
 						startSeconds: local.getTimeElapsed() / 1000 + local.currentSong.skipDuration,
 						playerVars: {controls: 0, iv_load_policy: 3, rel: 0, showinfo: 0},
 						events: {
@@ -201,7 +201,7 @@
 				let local = this;
 				if (local.playerReady) {
 					local.videoLoading = true;
-					local.player.loadVideoById(local.currentSong._id, local.getTimeElapsed() / 1000 + local.currentSong.skipDuration);
+					local.player.loadVideoById(local.currentSong.songId, local.getTimeElapsed() / 1000 + local.currentSong.skipDuration);
 
 					if (local.currentSong.artists) local.currentSong.artists = local.currentSong.artists.join(", ");
 					if (window.stationInterval !== 0) clearInterval(window.stationInterval);
@@ -344,9 +344,10 @@
 
 						_this.socket.emit('playlists.getFirstSong', _this.privatePlaylistQueueSelected, data => {
 							if (data.status === 'success') {
+								console.log(data.song);
 								let songId = data.song._id;
-								_this.automaticallyRequestedSongId = songId;
-								_this.socket.emit('stations.addToQueue', _this.stationId, songId, data => {
+								_this.automaticallyRequestedSongId = data.song.songId;
+								_this.socket.emit('stations.addToQueue', _this.stationId, data.song.songId, data => {
 									if (data.status === 'success') {
 										_this.socket.emit('playlists.moveSongToBottom', _this.privatePlaylistQueueSelected, songId, data => {
 											if (data.status === 'success') {}
@@ -482,7 +483,7 @@
 					_this.songsList.forEach((queueSong) => {
 						if (queueSong.requestedBy === userId) isInQueue = true;
 					});
-					if (!isInQueue && _this.privatePlaylistQueueSelected && (_this.automaticallyRequestedSongId !== _this.currentSong._id || !_this.currentSong._id)) {
+					if (!isInQueue && _this.privatePlaylistQueueSelected && (_this.automaticallyRequestedSongId !== _this.currentSong.songId || !_this.currentSong._id)) {
 						_this.addFirstPrivatePlaylistSongToQueue();
 					}
 				});