ソースを参照

fix: removing private playlist updates stations with that playlist selected

Kristian Vos 5 年 前
コミット
0892ed563d
1 ファイル変更28 行追加0 行削除
  1. 28 0
      backend/logic/actions/playlists.js

+ 28 - 0
backend/logic/actions/playlists.js

@@ -633,6 +633,34 @@ let lib = {
 		async.waterfall([
 			(next) => {
 				playlists.deletePlaylist(playlistId, next);
+			},
+
+			(next) => {
+				db.models.station.find({ privatePlaylist: playlistId }, next);
+			},
+
+			(stations, next) => {
+				async.each(
+					stations,
+					(station, next) => {
+						async.waterfall([
+							(next) => {
+								db.models.station.updateOne({_id: station._id}, {$set: {privatePlaylist: null}}, {runValidators: true}, next);
+							},
+
+							(res, next) => {
+								if (!station.partyMode) moduleManager.modules["stations"].updateStation(station._id, next);
+								else next();
+							}
+						], (err) => {
+							next();
+						}
+						);
+					},
+					(err) => {
+						next();
+					}
+				);
 			}
 		], async (err) => {
 			if (err) {