Browse Source

Added JavaDocs to all actions.

KrisVos130 8 years ago
parent
commit
26c4107bf5

+ 20 - 0
backend/logic/actions/apis.js

@@ -44,6 +44,13 @@ module.exports = {
 		});
 	},
 
+	/**
+	 * Joins a room
+	 *
+	 * @param session
+	 * @param page - the room to join
+	 * @param cb
+	 */
 	joinRoom: (session, page, cb) => {
 		if (page === 'home') {
 			utils.socketJoinRoom(session.socketId, page);
@@ -51,6 +58,13 @@ module.exports = {
 		cb({});
 	},
 
+	/**
+	 * Joins an admin room
+	 *
+	 * @param session
+	 * @param page - the admin room to join
+	 * @param cb
+	 */
 	joinAdminRoom: hooks.adminRequired((session, page, cb) => {
 		if (page === 'queue' || page === 'songs' || page === 'stations' || page === 'reports' || page === 'news' || page === 'users') {
 			utils.socketJoinRoom(session.socketId, `admin.${page}`);
@@ -58,6 +72,12 @@ module.exports = {
 		cb({});
 	}),
 
+	/**
+	 * Returns current date
+	 *
+	 * @param session
+	 * @param cb
+	 */
 	ping: (session, cb) => {
 		cb({date: Date.now()});
 	}

+ 7 - 0
backend/logic/actions/queueSongs.js

@@ -56,6 +56,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Gets a set of queue songs
+	 *
+	 * @param session
+	 * @param set - the set number to return
+	 * @param cb
+	 */
 	getSet: hooks.adminRequired((session, set, cb) => {
 		db.models.queueSong.find({}).limit(50 * set).exec((err, songs) => {
 			if (err) throw err;

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

@@ -63,6 +63,12 @@ cache.sub('song.undislike', (data) => {
 
 module.exports = {
 
+	/**
+	 * Returns the length of the songs list
+	 *
+	 * @param session
+	 * @param cb
+	 */
 	length: hooks.adminRequired((session, cb) => {
 		async.waterfall([
 			(next) => {
@@ -79,6 +85,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Gets a set of songs
+	 *
+	 * @param session
+	 * @param set - the set number to return
+	 * @param cb
+	 */
 	getSet: hooks.adminRequired((session, set, cb) => {
 		async.waterfall([
 			(next) => {
@@ -95,6 +108,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Updates a song
+	 *
+	 * @param session
+	 * @param songId - the song id
+	 * @param song - the updated song object
+	 * @param cb
+	 */
 	update: hooks.adminRequired((session, songId, song, cb) => {
 		async.waterfall([
 			(next) => {
@@ -116,6 +137,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Removes a song
+	 *
+	 * @param session
+	 * @param songId - the song id
+	 * @param cb
+	 */
 	remove: hooks.adminRequired((session, songId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -137,6 +165,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Adds a song
+	 *
+	 * @param session
+	 * @param song - the song object
+	 * @param cb
+	 * @param userId
+	 */
 	add: hooks.adminRequired((session, song, cb, userId) => {
 		async.waterfall([
 			(next) => {
@@ -173,6 +209,14 @@ module.exports = {
 		//TODO Check if video is in queue and Add the song to the appropriate stations
 	}),
 
+	/**
+	 * Likes a song
+	 *
+	 * @param session
+	 * @param songId - the song id
+	 * @param cb
+	 * @param userId
+	 */
 	like: hooks.loginRequired((session, songId, cb, userId) => {
 		db.models.user.findOne({ _id: userId }, (err, user) => {
 			if (user.liked.indexOf(songId) !== -1) return cb({ status: 'failure', message: 'You have already liked this song.' });
@@ -195,6 +239,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Dislikes a song
+	 *
+	 * @param session
+	 * @param songId - the song id
+	 * @param cb
+	 * @param userId
+	 */
 	dislike: hooks.loginRequired((session, songId, cb, userId) => {
 		db.models.user.findOne({ _id: userId }, (err, user) => {
 			if (user.disliked.indexOf(songId) !== -1) return cb({ status: 'failure', message: 'You have already disliked this song.' });
@@ -217,6 +269,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Undislikes a song
+	 *
+	 * @param session
+	 * @param songId - the song id
+	 * @param cb
+	 * @param userId
+	 */
 	undislike: hooks.loginRequired((session, songId, cb, userId) => {
 		db.models.user.findOne({ _id: userId }, (err, user) => {
 			if (user.disliked.indexOf(songId) === -1) return cb({ status: 'failure', message: 'You have not disliked this song.' });
@@ -239,6 +299,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Unlikes a song
+	 *
+	 * @param session
+	 * @param songId - the song id
+	 * @param cb
+	 * @param userId
+	 */
 	unlike: hooks.loginRequired((session, songId, cb, userId) => {
 		db.models.user.findOne({ _id: userId }, (err, user) => {
 			if (user.liked.indexOf(songId) === -1) return cb({ status: 'failure', message: 'You have not liked this song.' });
@@ -261,6 +329,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Gets user's own song ratings
+	 *
+	 * @param session
+	 * @param songId - the song id
+	 * @param cb
+	 * @param userId
+	 */
 	getOwnSongRatings: hooks.loginRequired((session, songId, cb, userId) => {
 		db.models.user.findOne({_id: userId}, (err, user) => {
 			if (!err && user) {

+ 119 - 2
backend/logic/actions/stations.js

@@ -136,6 +136,13 @@ module.exports = {
 		});
 	},
 
+	/**
+	 * Finds a station by id
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param cb
+	 */
 	find: (session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -157,6 +164,13 @@ module.exports = {
 		});
 	},
 
+	/**
+	 * Gets the official playlist for a station
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param cb
+	 */
 	getPlaylist: (session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -273,11 +287,12 @@ module.exports = {
 	},
 
 	/**
-	 * Skips the users current station
+	 * Votes to skip a station
 	 *
 	 * @param session
 	 * @param stationId - the station id
 	 * @param cb
+	 * @param userId
 	 */
 	voteSkip: hooks.loginRequired((session, stationId, cb, userId) => {
 		async.waterfall([
@@ -317,6 +332,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Force skips a station
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param cb
+	 */
 	forceSkip: hooks.ownerRequired((session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -341,7 +363,7 @@ module.exports = {
 	}),
 
 	/**
-	 * Leaves the users current station
+	 * Leaves the user's current station
 	 *
 	 * @param session
 	 * @param stationId
@@ -374,6 +396,14 @@ module.exports = {
 		});
 	},
 
+	/**
+	 * Updates a station's display name
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param newDisplayName - the new station display name
+	 * @param cb
+	 */
 	updateDisplayName: hooks.ownerRequired((session, stationId, newDisplayName, cb) => {
 		async.waterfall([
 			(next) => {
@@ -394,6 +424,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Updates a station's description
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param newDescription - the new station description
+	 * @param cb
+	 */
 	updateDescription: hooks.ownerRequired((session, stationId, newDescription, cb) => {
 		async.waterfall([
 			(next) => {
@@ -414,6 +452,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Updates a station's privacy
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param newPrivacy - the new station privacy
+	 * @param cb
+	 */
 	updatePrivacy: hooks.ownerRequired((session, stationId, newPrivacy, cb) => {
 		async.waterfall([
 			(next) => {
@@ -434,6 +480,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Updates a station's party mode
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param newPartyMode - the new station party mode
+	 * @param cb
+	 */
 	updatePartyMode: hooks.ownerRequired((session, stationId, newPartyMode, cb) => {
 		async.waterfall([
 			(next) => {
@@ -462,6 +516,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Pauses a station
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param cb
+	 */
 	pause: hooks.ownerRequired((session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -490,6 +551,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Resumes a station
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param cb
+	 */
 	resume: hooks.ownerRequired((session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -518,6 +586,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Removes a station
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param cb
+	 */
 	remove: hooks.ownerRequired((session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -539,6 +614,14 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Created a station
+	 *
+	 * @param session
+	 * @param data - the station data
+	 * @param cb
+	 * @param userId
+	 */
 	create: hooks.loginRequired((session, data, cb, userId) => {
 		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", "auth", "reset_password"];
@@ -598,6 +681,15 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Adds song to station queue
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param songId - the song id
+	 * @param cb
+	 * @param userId
+	 */
 	addToQueue: hooks.loginRequired((session, stationId, songId, cb, userId) => {
 		async.waterfall([
 			(next) => {
@@ -651,6 +743,15 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Removes song from station queue
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param songId - the song id
+	 * @param cb
+	 * @param userId
+	 */
 	removeFromQueue: hooks.ownerRequired((session, stationId, songId, cb, userId) => {
 		async.waterfall([
 			(next) => {
@@ -689,6 +790,13 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Gets the queue from a station
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param cb
+	 */
 	getQueue: hooks.adminRequired((session, stationId, cb) => {
 		async.waterfall([
 			(next) => {
@@ -711,6 +819,15 @@ module.exports = {
 		});
 	}),
 
+	/**
+	 * Selects a private playlist for a station
+	 *
+	 * @param session
+	 * @param stationId - the station id
+	 * @param playlistId - the private playlist id
+	 * @param cb
+	 * @param userId
+	 */
 	selectPrivatePlaylist: hooks.ownerRequired((session, stationId, playlistId, cb, userId) => {
 		async.waterfall([
 			(next) => {