playlists.js 21 KB

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