浏览代码

fix: more bug fixes

Kristian Vos 5 年之前
父节点
当前提交
1a588ab0f8
共有 4 个文件被更改,包括 28 次插入21 次删除
  1. 4 1
      backend/logic/actions/hooks/ownerRequired.js
  2. 13 14
      backend/logic/actions/playlists.js
  3. 9 4
      backend/logic/stations.js
  4. 2 2
      backend/logic/utils.js

+ 4 - 1
backend/logic/actions/hooks/ownerRequired.js

@@ -33,7 +33,10 @@ module.exports = function(next) {
                 (user, next) => {
                     if (!user) return next("Login required.");
                     if (user.role === "admin") return next(true);
-                    stations.getStation(stationId, next);
+                    stations
+                        .runJob("GET_STATION", { stationId })
+                        .then((station) => next(null, station))
+                        .catch(next);
                 },
                 (station, next) => {
                     if (!station) return next("Station not found.");

+ 13 - 14
backend/logic/actions/playlists.js

@@ -495,6 +495,7 @@ let lib = {
             const playlistModel = await db.runJob("GET_MODEL", {
                 modelName: "playlist",
             });
+
             async.waterfall(
                 [
                     (next) => {
@@ -629,20 +630,18 @@ let lib = {
                                 url,
                                 musicOnly,
                             })
-                            .then(
-                                (songIds,
-                                (otherSongIds) => {
-                                    if (otherSongIds) {
-                                        videosInPlaylistTotal = songIds.length;
-                                        songsInPlaylistTotal =
-                                            otherSongIds.length;
-                                    } else {
-                                        songsInPlaylistTotal = videosInPlaylistTotal =
-                                            songIds.length;
-                                    }
-                                    next(null, songIds);
-                                })
-                            );
+                            .then((response) => {
+                                if (response.filteredSongs) {
+                                    videosInPlaylistTotal =
+                                        response.songs.length;
+                                    songsInPlaylistTotal =
+                                        response.filteredSongs.length;
+                                } else {
+                                    songsInPlaylistTotal = videosInPlaylistTotal =
+                                        response.songs.length;
+                                }
+                                next(null, response.songs);
+                            });
                     },
                     (songIds, next) => {
                         let processed = 0;

+ 9 - 4
backend/logic/stations.js

@@ -926,10 +926,15 @@ class StationsModule extends CoreClass {
                             { _id: station._id },
                             { $set },
                             (err) => {
-                                this.runJob("UPDATE_STATION", {
-                                    stationId: station._id,
-                                    bypassQueue: payload.bypassQueue,
-                                })
+                                this.runJob(
+                                    "UPDATE_STATION",
+                                    {
+                                        stationId: station._id,
+                                        bypassQueue: payload.bypassQueue,
+                                    },
+
+                                    { bypassQueue: payload.bypassQueue }
+                                )
                                     .then((station) => {
                                         if (
                                             station.type === "community" &&

+ 2 - 2
backend/logic/utils.js

@@ -510,7 +510,7 @@ class UtilsModule extends CoreClass {
                             const songId = item.id;
                             if (!item.topicDetails) return;
                             else if (
-                                item.topicDetails.topicIds.indexOf(
+                                item.topicDetails.relevantTopicIds.indexOf(
                                     "/m/04rlf"
                                 ) !== -1
                             ) {
@@ -576,7 +576,7 @@ class UtilsModule extends CoreClass {
                                     .runJob("FILTER_MUSIC_VIDEOS_YOUTUBE", {
                                         videoIds: songs.slice(),
                                     })
-                                    .resolve((filteredSongs) => {
+                                    .then((filteredSongs) => {
                                         resolve({ filteredSongs, songs });
                                     });
                             }