Browse Source

fix: Added missing createMissingArtistPlaylists function

Owen Diffey 3 years ago
parent
commit
2b0e085272
1 changed files with 46 additions and 0 deletions
  1. 46 0
      backend/logic/actions/playlists.js

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

@@ -2412,5 +2412,51 @@ export default {
 				});
 			}
 		);
+	}),
+
+	/**
+	 * Create missing artist playlists
+	 *
+	 * @param {object} session - the session object automatically added by socket.io
+	 * @param {Function} cb - gets called with the result
+	 */
+	createMissingArtistPlaylists: isAdminRequired(async function index(session, cb) {
+		async.waterfall(
+			[
+				next => {
+					PlaylistsModule.runJob("CREATE_MISSING_ARTIST_PLAYLISTS", this)
+						.then(() => {
+							next();
+						})
+						.catch(err => {
+							next(err);
+						});
+				}
+			],
+			async err => {
+				if (err) {
+					err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
+
+					this.log(
+						"ERROR",
+						"PLAYLIST_CREATE_MISSING_ARTIST_PLAYLISTS",
+						`Creating missing artist playlists failed for user "${session.userId}". "${err}"`
+					);
+
+					return cb({ status: "error", message: err });
+				}
+
+				this.log(
+					"SUCCESS",
+					"PLAYLIST_CREATE_MISSING_ARTIST_PLAYLISTS",
+					`Successfully created missing artist playlists for user "${session.userId}".`
+				);
+
+				return cb({
+					status: "success",
+					message: "Missing artist playlists have been successfully created"
+				});
+			}
+		);
 	})
 };