playlists.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. 'use strict';
  2. const async = require('async');
  3. const hooks = require('./hooks');
  4. const moduleManager = require("../../index");
  5. const db = moduleManager.modules["db"];
  6. const cache = moduleManager.modules["cache"];
  7. const utils = moduleManager.modules["utils"];
  8. const logger = moduleManager.modules["logger"];
  9. const playlists = moduleManager.modules["playlists"];
  10. const songs = moduleManager.modules["songs"];
  11. cache.sub('playlist.create', playlistId => {
  12. playlists.getPlaylist(playlistId, (err, playlist) => {
  13. if (!err) {
  14. utils.socketsFromUser(playlist.createdBy, (sockets) => {
  15. sockets.forEach(socket => {
  16. socket.emit('event:playlist.create', playlist);
  17. });
  18. });
  19. }
  20. });
  21. });
  22. cache.sub('playlist.delete', res => {
  23. utils.socketsFromUser(res.userId, sockets => {
  24. sockets.forEach(socket => {
  25. socket.emit('event:playlist.delete', res.playlistId);
  26. });
  27. });
  28. });
  29. cache.sub('playlist.moveSongToTop', res => {
  30. utils.socketsFromUser(res.userId, sockets => {
  31. sockets.forEach(socket => {
  32. socket.emit('event:playlist.moveSongToTop', {playlistId: res.playlistId, songId: res.songId});
  33. });
  34. });
  35. });
  36. cache.sub('playlist.moveSongToBottom', res => {
  37. utils.socketsFromUser(res.userId, sockets => {
  38. sockets.forEach(socket => {
  39. socket.emit('event:playlist.moveSongToBottom', {playlistId: res.playlistId, songId: res.songId});
  40. });
  41. });
  42. });
  43. cache.sub('playlist.addSong', res => {
  44. utils.socketsFromUser(res.userId, sockets => {
  45. sockets.forEach(socket => {
  46. socket.emit('event:playlist.addSong', { playlistId: res.playlistId, song: res.song });
  47. });
  48. });
  49. });
  50. cache.sub('playlist.removeSong', res => {
  51. utils.socketsFromUser(res.userId, sockets => {
  52. sockets.forEach(socket => {
  53. socket.emit('event:playlist.removeSong', { playlistId: res.playlistId, songId: res.songId });
  54. });
  55. });
  56. });
  57. cache.sub('playlist.updateDisplayName', res => {
  58. utils.socketsFromUser(res.userId, sockets => {
  59. sockets.forEach(socket => {
  60. socket.emit('event:playlist.updateDisplayName', { playlistId: res.playlistId, displayName: res.displayName });
  61. });
  62. });
  63. });
  64. let lib = {
  65. /**
  66. * Gets the first song from a private playlist
  67. *
  68. * @param {Object} session - the session object automatically added by socket.io
  69. * @param {String} playlistId - the id of the playlist we are getting the first song from
  70. * @param {Function} cb - gets called with the result
  71. */
  72. getFirstSong: hooks.loginRequired((session, playlistId, cb) => {
  73. async.waterfall([
  74. (next) => {
  75. playlists.getPlaylist(playlistId, next);
  76. },
  77. (playlist, next) => {
  78. if (!playlist || playlist.createdBy !== session.userId) return next('Playlist not found.');
  79. next(null, playlist.songs[0]);
  80. }
  81. ], async (err, song) => {
  82. if (err) {
  83. err = await utils.getError(err);
  84. logger.error("PLAYLIST_GET_FIRST_SONG", `Getting the first song of playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  85. return cb({ status: 'failure', message: err});
  86. }
  87. logger.success("PLAYLIST_GET_FIRST_SONG", `Successfully got the first song of playlist "${playlistId}" for user "${session.userId}".`);
  88. cb({
  89. status: 'success',
  90. song: song
  91. });
  92. });
  93. }),
  94. /**
  95. * Gets all playlists for the user requesting it
  96. *
  97. * @param {Object} session - the session object automatically added by socket.io
  98. * @param {Function} cb - gets called with the result
  99. */
  100. indexForUser: hooks.loginRequired((session, cb) => {
  101. async.waterfall([
  102. (next) => {
  103. db.models.playlist.find({ createdBy: session.userId }, next);
  104. }
  105. ], async (err, playlists) => {
  106. if (err) {
  107. err = await utils.getError(err);
  108. logger.error("PLAYLIST_INDEX_FOR_USER", `Indexing playlists for user "${session.userId}" failed. "${err}"`);
  109. return cb({ status: 'failure', message: err});
  110. }
  111. logger.success("PLAYLIST_INDEX_FOR_USER", `Successfully indexed playlists for user "${session.userId}".`);
  112. cb({
  113. status: 'success',
  114. data: playlists
  115. });
  116. });
  117. }),
  118. /**
  119. * Creates a new private playlist
  120. *
  121. * @param {Object} session - the session object automatically added by socket.io
  122. * @param {Object} data - the data for the new private playlist
  123. * @param {Function} cb - gets called with the result
  124. */
  125. create: hooks.loginRequired((session, data, cb) => {
  126. async.waterfall([
  127. (next) => {
  128. return (data) ? next() : cb({ 'status': 'failure', 'message': 'Invalid data' });
  129. },
  130. (next) => {
  131. const { displayName, songs } = data;
  132. db.models.playlist.create({
  133. displayName,
  134. songs,
  135. createdBy: session.userId,
  136. createdAt: Date.now()
  137. }, next);
  138. }
  139. ], async (err, playlist) => {
  140. if (err) {
  141. err = await utils.getError(err);
  142. logger.error("PLAYLIST_CREATE", `Creating private playlist failed for user "${session.userId}". "${err}"`);
  143. return cb({ status: 'failure', message: err});
  144. }
  145. cache.pub('playlist.create', playlist._id);
  146. logger.success("PLAYLIST_CREATE", `Successfully created private playlist for user "${session.userId}".`);
  147. cb({ status: 'success', message: 'Successfully created playlist', data: {
  148. _id: playlist._id
  149. } });
  150. });
  151. }),
  152. /**
  153. * Gets a playlist from id
  154. *
  155. * @param {Object} session - the session object automatically added by socket.io
  156. * @param {String} playlistId - the id of the playlist we are getting
  157. * @param {Function} cb - gets called with the result
  158. */
  159. getPlaylist: hooks.loginRequired((session, playlistId, cb) => {
  160. async.waterfall([
  161. (next) => {
  162. playlists.getPlaylist(playlistId, next);
  163. },
  164. (playlist, next) => {
  165. if (!playlist || playlist.createdBy !== session.userId) return next('Playlist not found');
  166. next(null, playlist);
  167. }
  168. ], async (err, playlist) => {
  169. if (err) {
  170. err = await utils.getError(err);
  171. logger.error("PLAYLIST_GET", `Getting private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  172. return cb({ status: 'failure', message: err});
  173. }
  174. logger.success("PLAYLIST_GET", `Successfully got private playlist "${playlistId}" for user "${session.userId}".`);
  175. cb({
  176. status: 'success',
  177. data: playlist
  178. });
  179. });
  180. }),
  181. //TODO Remove this
  182. /**
  183. * Updates a private playlist
  184. *
  185. * @param {Object} session - the session object automatically added by socket.io
  186. * @param {String} playlistId - the id of the playlist we are updating
  187. * @param {Object} playlist - the new private playlist object
  188. * @param {Function} cb - gets called with the result
  189. */
  190. update: hooks.loginRequired((session, playlistId, playlist, cb) => {
  191. async.waterfall([
  192. (next) => {
  193. db.models.playlist.updateOne({ _id: playlistId, createdBy: session.userId }, playlist, {runValidators: true}, next);
  194. },
  195. (res, next) => {
  196. playlists.updatePlaylist(playlistId, next)
  197. }
  198. ], async (err, playlist) => {
  199. if (err) {
  200. err = await utils.getError(err);
  201. logger.error("PLAYLIST_UPDATE", `Updating private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  202. return cb({ status: 'failure', message: err});
  203. }
  204. logger.success("PLAYLIST_UPDATE", `Successfully updated private playlist "${playlistId}" for user "${session.userId}".`);
  205. cb({
  206. status: 'success',
  207. data: playlist
  208. });
  209. });
  210. }),
  211. /**
  212. * Updates a private playlist
  213. *
  214. * @param {Object} session - the session object automatically added by socket.io
  215. * @param {String} playlistId - the id of the playlist we are updating
  216. * @param {Function} cb - gets called with the result
  217. */
  218. shuffle: hooks.loginRequired((session, playlistId, cb) => {
  219. async.waterfall([
  220. (next) => {
  221. if (!playlistId) return next("No playlist id.");
  222. db.models.playlist.findById(playlistId, next);
  223. },
  224. (playlist, next) => {
  225. utils.shuffle(playlist.songs).then(songs => {
  226. next(null, songs);
  227. }).catch(next);
  228. },
  229. (songs, next) => {
  230. db.models.playlist.updateOne({ _id: playlistId }, { $set: { songs } }, { runValidators: true }, next);
  231. },
  232. (res, next) => {
  233. playlists.updatePlaylist(playlistId, next)
  234. }
  235. ], async (err, playlist) => {
  236. if (err) {
  237. err = await utils.getError(err);
  238. logger.error("PLAYLIST_SHUFFLE", `Updating private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  239. return cb({ status: 'failure', message: err});
  240. }
  241. logger.success("PLAYLIST_SHUFFLE", `Successfully updated private playlist "${playlistId}" for user "${session.userId}".`);
  242. cb({
  243. status: 'success',
  244. message: "Successfully shuffled playlist.",
  245. data: playlist
  246. });
  247. });
  248. }),
  249. /**
  250. * Adds a song to a private playlist
  251. *
  252. * @param {Object} session - the session object automatically added by socket.io
  253. * @param {String} songId - the id of the song we are trying to add
  254. * @param {String} playlistId - the id of the playlist we are adding the song to
  255. * @param {Function} cb - gets called with the result
  256. */
  257. addSongToPlaylist: hooks.loginRequired((session, songId, playlistId, cb) => {
  258. async.waterfall([
  259. (next) => {
  260. playlists.getPlaylist(playlistId, (err, playlist) => {
  261. if (err || !playlist || playlist.createdBy !== session.userId) return next('Something went wrong when trying to get the playlist');
  262. async.each(playlist.songs, (song, next) => {
  263. if (song.songId === songId) return next('That song is already in the playlist');
  264. next();
  265. }, next);
  266. });
  267. },
  268. (next) => {
  269. songs.getSong(songId, (err, song) => {
  270. if (err) {
  271. utils.getSongFromYouTube(songId, (song) => {
  272. next(null, song);
  273. });
  274. } else {
  275. next(null, {
  276. _id: song._id,
  277. songId: songId,
  278. title: song.title,
  279. duration: song.duration
  280. });
  281. }
  282. });
  283. },
  284. (newSong, next) => {
  285. db.models.playlist.updateOne({_id: playlistId}, {$push: {songs: newSong}}, {runValidators: true}, (err) => {
  286. if (err) return next(err);
  287. playlists.updatePlaylist(playlistId, (err, playlist) => {
  288. next(err, playlist, newSong);
  289. });
  290. });
  291. }
  292. ],
  293. async (err, playlist, newSong) => {
  294. if (err) {
  295. err = await utils.getError(err);
  296. logger.error("PLAYLIST_ADD_SONG", `Adding song "${songId}" to private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  297. return cb({ status: 'failure', message: err});
  298. } else {
  299. logger.success("PLAYLIST_ADD_SONG", `Successfully added song "${songId}" to private playlist "${playlistId}" for user "${session.userId}".`);
  300. cache.pub('playlist.addSong', { playlistId: playlist._id, song: newSong, userId: session.userId });
  301. return cb({ status: 'success', message: 'Song has been successfully added to the playlist', data: playlist.songs });
  302. }
  303. });
  304. }),
  305. /**
  306. * Adds a set of songs to a private playlist
  307. *
  308. * @param {Object} session - the session object automatically added by socket.io
  309. * @param {String} url - the url of the the YouTube playlist
  310. * @param {String} playlistId - the id of the playlist we are adding the set of songs to
  311. * @param {Boolean} musicOnly - whether to only add music to the playlist
  312. * @param {Function} cb - gets called with the result
  313. */
  314. addSetToPlaylist: hooks.loginRequired((session, url, playlistId, musicOnly, cb) => {
  315. let videosInPlaylistTotal = 0;
  316. let songsInPlaylistTotal = 0;
  317. let songsSuccess = 0;
  318. let songsFail = 0;
  319. async.waterfall([
  320. (next) => {
  321. utils.getPlaylistFromYouTube(url, musicOnly, (songIds, otherSongIds) => {
  322. if (otherSongIds) {
  323. videosInPlaylistTotal = songIds.length;
  324. songsInPlaylistTotal = otherSongIds.length;
  325. } else {
  326. songsInPlaylistTotal = videosInPlaylistTotal = songIds.length;
  327. }
  328. next(null, songIds);
  329. });
  330. },
  331. (songIds, next) => {
  332. let processed = 0;
  333. function checkDone() {
  334. if (processed === songIds.length) next();
  335. }
  336. for (let s = 0; s < songIds.length; s++) {
  337. lib.addSongToPlaylist(session, songIds[s], playlistId, (res) => {
  338. processed++;
  339. if (res.status === "success") songsSuccess++;
  340. else songsFail++;
  341. checkDone();
  342. });
  343. }
  344. },
  345. (next) => {
  346. playlists.getPlaylist(playlistId, next);
  347. },
  348. (playlist, next) => {
  349. if (!playlist || playlist.createdBy !== session.userId) return next('Playlist not found.');
  350. next(null, playlist);
  351. }
  352. ], async (err, playlist) => {
  353. if (err) {
  354. err = await utils.getError(err);
  355. logger.error("PLAYLIST_IMPORT", `Importing a YouTube playlist to private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  356. return cb({ status: 'failure', message: err});
  357. } else {
  358. logger.success("PLAYLIST_IMPORT", `Successfully imported a YouTube playlist to private playlist "${playlistId}" for user "${session.userId}". Videos in playlist: ${videosInPlaylistTotal}, songs in playlist: ${songsInPlaylistTotal}, songs successfully added: ${songsSuccess}, songs failed: ${songsFail}.`);
  359. cb({
  360. status: 'success',
  361. message: 'Playlist has been successfully imported.',
  362. data: playlist.songs,
  363. stats: {
  364. videosInPlaylistTotal,
  365. songsInPlaylistTotal,
  366. songsAddedSuccessfully: songsSuccess,
  367. songsFailedToAdd: songsFail
  368. }
  369. });
  370. }
  371. });
  372. }),
  373. /**
  374. * Removes a song from a private playlist
  375. *
  376. * @param {Object} session - the session object automatically added by socket.io
  377. * @param {String} songId - the id of the song we are removing from the private playlist
  378. * @param {String} playlistId - the id of the playlist we are removing the song from
  379. * @param {Function} cb - gets called with the result
  380. */
  381. removeSongFromPlaylist: hooks.loginRequired((session, songId, playlistId, cb) => {
  382. async.waterfall([
  383. (next) => {
  384. if (!songId || typeof songId !== 'string') return next('Invalid song id.');
  385. if (!playlistId || typeof playlistId !== 'string') return next('Invalid playlist id.');
  386. next();
  387. },
  388. (next) => {
  389. playlists.getPlaylist(playlistId, next);
  390. },
  391. (playlist, next) => {
  392. if (!playlist || playlist.createdBy !== session.userId) return next('Playlist not found');
  393. db.models.playlist.updateOne({_id: playlistId}, {$pull: {songs: {songId: songId}}}, next);
  394. },
  395. (res, next) => {
  396. playlists.updatePlaylist(playlistId, next);
  397. }
  398. ], async (err, playlist) => {
  399. if (err) {
  400. err = await utils.getError(err);
  401. logger.error("PLAYLIST_REMOVE_SONG", `Removing song "${songId}" from private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  402. return cb({ status: 'failure', message: err});
  403. } else {
  404. logger.success("PLAYLIST_REMOVE_SONG", `Successfully removed song "${songId}" from private playlist "${playlistId}" for user "${session.userId}".`);
  405. cache.pub('playlist.removeSong', { playlistId: playlist._id, songId: songId, userId: session.userId });
  406. return cb({ status: 'success', message: 'Song has been successfully removed from playlist', data: playlist.songs });
  407. }
  408. });
  409. }),
  410. /**
  411. * Updates the displayName of a private playlist
  412. *
  413. * @param {Object} session - the session object automatically added by socket.io
  414. * @param {String} playlistId - the id of the playlist we are updating the displayName for
  415. * @param {Function} cb - gets called with the result
  416. */
  417. updateDisplayName: hooks.loginRequired((session, playlistId, displayName, cb) => {
  418. async.waterfall([
  419. (next) => {
  420. db.models.playlist.updateOne({ _id: playlistId, createdBy: session.userId }, { $set: { displayName } }, {runValidators: true}, next);
  421. },
  422. (res, next) => {
  423. playlists.updatePlaylist(playlistId, next);
  424. }
  425. ], async (err, playlist) => {
  426. if (err) {
  427. err = await utils.getError(err);
  428. logger.error("PLAYLIST_UPDATE_DISPLAY_NAME", `Updating display name to "${displayName}" for private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  429. return cb({ status: 'failure', message: err});
  430. }
  431. logger.success("PLAYLIST_UPDATE_DISPLAY_NAME", `Successfully updated display name to "${displayName}" for private playlist "${playlistId}" for user "${session.userId}".`);
  432. cache.pub('playlist.updateDisplayName', {playlistId: playlistId, displayName: displayName, userId: session.userId});
  433. return cb({ status: 'success', message: 'Playlist has been successfully updated' });
  434. });
  435. }),
  436. /**
  437. * Moves a song to the top of the list in a private playlist
  438. *
  439. * @param {Object} session - the session object automatically added by socket.io
  440. * @param {String} playlistId - the id of the playlist we are moving the song to the top from
  441. * @param {String} songId - the id of the song we are moving to the top of the list
  442. * @param {Function} cb - gets called with the result
  443. */
  444. moveSongToTop: hooks.loginRequired((session, playlistId, songId, cb) => {
  445. async.waterfall([
  446. (next) => {
  447. playlists.getPlaylist(playlistId, next);
  448. },
  449. (playlist, next) => {
  450. if (!playlist || playlist.createdBy !== session.userId) return next('Playlist not found');
  451. async.each(playlist.songs, (song, next) => {
  452. if (song.songId === songId) return next(song);
  453. next();
  454. }, (err) => {
  455. if (err && err.songId) return next(null, err);
  456. next('Song not found');
  457. });
  458. },
  459. (song, next) => {
  460. db.models.playlist.updateOne({_id: playlistId}, {$pull: {songs: {songId}}}, (err) => {
  461. if (err) return next(err);
  462. return next(null, song);
  463. });
  464. },
  465. (song, next) => {
  466. db.models.playlist.updateOne({_id: playlistId}, {
  467. $push: {
  468. songs: {
  469. $each: [song],
  470. $position: 0
  471. }
  472. }
  473. }, next);
  474. },
  475. (res, next) => {
  476. playlists.updatePlaylist(playlistId, next);
  477. }
  478. ], async (err, playlist) => {
  479. if (err) {
  480. err = await utils.getError(err);
  481. logger.error("PLAYLIST_MOVE_SONG_TO_TOP", `Moving song "${songId}" to the top for private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  482. return cb({ status: 'failure', message: err});
  483. }
  484. logger.success("PLAYLIST_MOVE_SONG_TO_TOP", `Successfully moved song "${songId}" to the top for private playlist "${playlistId}" for user "${session.userId}".`);
  485. cache.pub('playlist.moveSongToTop', {playlistId, songId, userId: session.userId});
  486. return cb({ status: 'success', message: 'Playlist has been successfully updated' });
  487. });
  488. }),
  489. /**
  490. * Moves a song to the bottom of the list in a private playlist
  491. *
  492. * @param {Object} session - the session object automatically added by socket.io
  493. * @param {String} playlistId - the id of the playlist we are moving the song to the bottom from
  494. * @param {String} songId - the id of the song we are moving to the bottom of the list
  495. * @param {Function} cb - gets called with the result
  496. */
  497. moveSongToBottom: hooks.loginRequired((session, playlistId, songId, cb) => {
  498. async.waterfall([
  499. (next) => {
  500. playlists.getPlaylist(playlistId, next);
  501. },
  502. (playlist, next) => {
  503. if (!playlist || playlist.createdBy !== session.userId) return next('Playlist not found');
  504. async.each(playlist.songs, (song, next) => {
  505. if (song.songId === songId) return next(song);
  506. next();
  507. }, (err) => {
  508. if (err && err.songId) return next(null, err);
  509. next('Song not found');
  510. });
  511. },
  512. (song, next) => {
  513. db.models.playlist.updateOne({_id: playlistId}, {$pull: {songs: {songId}}}, (err) => {
  514. if (err) return next(err);
  515. return next(null, song);
  516. });
  517. },
  518. (song, next) => {
  519. db.models.playlist.updateOne({_id: playlistId}, {
  520. $push: {
  521. songs: song
  522. }
  523. }, next);
  524. },
  525. (res, next) => {
  526. playlists.updatePlaylist(playlistId, next);
  527. }
  528. ], async (err, playlist) => {
  529. if (err) {
  530. err = await utils.getError(err);
  531. logger.error("PLAYLIST_MOVE_SONG_TO_BOTTOM", `Moving song "${songId}" to the bottom for private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  532. return cb({ status: 'failure', message: err});
  533. }
  534. logger.success("PLAYLIST_MOVE_SONG_TO_BOTTOM", `Successfully moved song "${songId}" to the bottom for private playlist "${playlistId}" for user "${session.userId}".`);
  535. cache.pub('playlist.moveSongToBottom', {playlistId, songId, userId: session.userId});
  536. return cb({ status: 'success', message: 'Playlist has been successfully updated' });
  537. });
  538. }),
  539. /**
  540. * Removes a private playlist
  541. *
  542. * @param {Object} session - the session object automatically added by socket.io
  543. * @param {String} playlistId - the id of the playlist we are moving the song to the top from
  544. * @param {Function} cb - gets called with the result
  545. */
  546. remove: hooks.loginRequired((session, playlistId, cb) => {
  547. async.waterfall([
  548. (next) => {
  549. playlists.deletePlaylist(playlistId, next);
  550. }
  551. ], async (err) => {
  552. if (err) {
  553. err = await utils.getError(err);
  554. logger.error("PLAYLIST_REMOVE", `Removing private playlist "${playlistId}" failed for user "${session.userId}". "${err}"`);
  555. return cb({ status: 'failure', message: err});
  556. }
  557. logger.success("PLAYLIST_REMOVE", `Successfully removed private playlist "${playlistId}" for user "${session.userId}".`);
  558. cache.pub('playlist.delete', {userId: session.userId, playlistId});
  559. return cb({ status: 'success', message: 'Playlist successfully removed' });
  560. });
  561. })
  562. };
  563. module.exports = lib;