Explorar o código

feat: Configurable blacklisted station names

Owen Diffey %!s(int64=3) %!d(string=hai) anos
pai
achega
8562cefbb1
Modificáronse 4 ficheiros con 13 adicións e 14 borrados
  1. 1 0
      .wiki/Configuration.md
  2. 2 1
      backend/config/template.json
  3. 1 1
      backend/index.js
  4. 9 12
      backend/logic/actions/stations.js

+ 1 - 0
.wiki/Configuration.md

@@ -40,6 +40,7 @@ Location: `backend/config/default.json`
 | `cookie.domain` | The ip or address you use to access the site, without protocols (http/https), so for example `localhost`. |
 | `cookie.secure` | Should be `true` for SSL connections, and `false` for normal http connections. |
 | `cookie.SIDname` | Name of the cookie stored for sessions. |
+| `blacklistedStationNames` | Array of blacklisted station names. |
 | `skipConfigVersionCheck` | Skips checking if the config version is outdated or not. Should almost always be set to false. |
 | `skipDbDocumentsVersionCheck` | Skips checking if there are any DB documents outdated or not. Should almost always be set to false. |
 | `debug.stationIssue` | If set to `true` it will enable the `/debug_station` API endpoint on the backend, which provides information useful to debugging stations not skipping, as well as capure all jobs specified in `debug.captureJobs`. 

+ 2 - 1
backend/config/template.json

@@ -59,6 +59,7 @@
 		"secure": false,
 		"SIDname": "SID"
 	},
+	"blacklistedStationNames": ["musare"],
 	"skipConfigVersionCheck": false,
 	"skipDbDocumentsVersionCheck": false,
 	"debug": {
@@ -91,5 +92,5 @@
 			]
 		}
 	},
-	"configVersion": 6
+	"configVersion": 7
 }

+ 1 - 1
backend/index.js

@@ -3,7 +3,7 @@ import "./loadEnvVariables.js";
 import util from "util";
 import config from "config";
 
-const REQUIRED_CONFIG_VERSION = 6;
+const REQUIRED_CONFIG_VERSION = 7;
 
 // eslint-disable-next-line
 Array.prototype.remove = function (item) {

+ 9 - 12
backend/logic/actions/stations.js

@@ -1,5 +1,6 @@
 import async from "async";
 import mongoose from "mongoose";
+import config from "config";
 
 import { isLoginRequired, isOwnerRequired, isAdminRequired } from "./hooks";
 
@@ -2539,16 +2540,7 @@ export default {
 
 		data.name = data.name.toLowerCase();
 
-		const blacklist = [
-			"country",
-			"edm",
-			"musare",
-			"hip-hop",
-			"rap",
-			"top-hits",
-			"todays-hits",
-			"old-school",
-			"christmas",
+		let blacklist = [
 			"about",
 			"support",
 			"staff",
@@ -2565,7 +2557,6 @@ export default {
 			"p",
 			"official",
 			"o",
-			"trap",
 			"faq",
 			"team",
 			"donate",
@@ -2581,9 +2572,15 @@ export default {
 			"api",
 			"songs",
 			"playlists",
-			"playlist"
+			"playlist",
+			"albums",
+			"artists",
+			"artist",
+			"station"
 		];
 
+		if (config.get("blacklistedStationNames")) blacklist = [...blacklist, ...config.get("blacklistedStationNames")];
+
 		async.waterfall(
 			[
 				next => {