Browse Source

fix: Disable youtube channel permissions if spotify disabled

Owen Diffey 1 năm trước cách đây
mục cha
commit
707b3d99cd

+ 33 - 43
backend/logic/hooks/hasPermission.js

@@ -36,7 +36,6 @@ permissions.moderator = {
 	"admin.view.songs": true,
 	"admin.view.stations": true,
 	"admin.view.users": true,
-	"admin.view.youtubeChannels": true,
 	"admin.view.youtubeVideos": true,
 	"apis.searchDiscogs": true,
 	"news.create": true,
@@ -66,8 +65,27 @@ permissions.moderator = {
 	"users.requestPasswordReset": true,
 	"users.resendVerifyEmail": true,
 	"users.update": true,
-	"youtube.getChannel": true,
-	"youtube.requestSetAdmin": true
+	"youtube.requestSetAdmin": true,
+	...(config.get("experimental.soundcloud")
+		? {
+				"admin.view.soundcloudTracks": true,
+				"admin.view.soundcloud": true,
+				"soundcloud.getArtist": true
+		  }
+		: {}),
+	...(config.get("experimental.spotify")
+		? {
+				"admin.view.spotify": true,
+				"spotify.getTracksFromMediaSources": true,
+				"spotify.getAlbumsFromIds": true,
+				"spotify.getArtistsFromIds": true,
+				"spotify.getAlternativeArtistSourcesForArtists": true,
+				"spotify.getAlternativeAlbumSourcesForAlbums": true,
+				"spotify.getAlternativeMediaSourcesForTracks": true,
+				"admin.view.youtubeChannels": true,
+				"youtube.getChannel": true
+		  }
+		: {})
 };
 permissions.admin = {
 	...permissions.moderator,
@@ -95,52 +113,24 @@ permissions.admin = {
 	"users.update.restricted": true,
 	"utils.getModules": true,
 	"youtube.getApiRequest": true,
-	"youtube.getMissingChannels": true,
 	"youtube.getMissingVideos": true,
 	"youtube.resetStoredApiRequests": true,
 	"youtube.removeStoredApiRequest": true,
 	"youtube.removeVideos": true,
-	"youtube.updateVideosV1ToV2": true
+	"youtube.updateVideosV1ToV2": true,
+	...(config.get("experimental.soundcloud")
+		? {
+				"soundcloud.fetchNewApiKey": true,
+				"soundcloud.testApiKey": true
+		  }
+		: {}),
+	...(config.get("experimental.spotify")
+		? {
+				"youtube.getMissingChannels": true
+		  }
+		: {})
 };
 
-if (config.get("experimental.soundcloud")) {
-	permissions.moderator["admin.view.soundcloudTracks"] = true;
-	permissions.admin["admin.view.soundcloudTracks"] = true;
-
-	permissions.moderator["admin.view.soundcloud"] = true;
-	permissions.admin["admin.view.soundcloud"] = true;
-
-	permissions.admin["soundcloud.fetchNewApiKey"] = true;
-
-	permissions.admin["soundcloud.testApiKey"] = true;
-
-	permissions.moderator["soundcloud.getArtist"] = true;
-	permissions.admin["soundcloud.getArtist"] = true;
-}
-
-if (config.get("experimental.spotify")) {
-	permissions.moderator["admin.view.spotify"] = true;
-	permissions.admin["admin.view.spotify"] = true;
-
-	permissions.moderator["spotify.getTracksFromMediaSources"] = true;
-	permissions.admin["spotify.getTracksFromMediaSources"] = true;
-
-	permissions.moderator["spotify.getAlbumsFromIds"] = true;
-	permissions.admin["spotify.getAlbumsFromIds"] = true;
-
-	permissions.moderator["spotify.getArtistsFromIds"] = true;
-	permissions.admin["spotify.getArtistsFromIds"] = true;
-
-	permissions.moderator["spotify.getAlternativeArtistSourcesForArtists"] = true;
-	permissions.admin["spotify.getAlternativeArtistSourcesForArtists"] = true;
-
-	permissions.moderator["spotify.getAlternativeAlbumSourcesForAlbums"] = true;
-	permissions.admin["spotify.getAlternativeAlbumSourcesForAlbums"] = true;
-
-	permissions.moderator["spotify.getAlternativeMediaSourcesForTracks"] = true;
-	permissions.admin["spotify.getAlternativeMediaSourcesForTracks"] = true;
-}
-
 export const hasPermission = async (permission, session, stationId) => {
 	const CacheModule = moduleManager.modules.cache;
 	const DBModule = moduleManager.modules.db;

+ 2 - 2
backend/logic/stations.js

@@ -127,9 +127,9 @@ class _StationsModule extends CoreClass {
 		const stationModel = (this.stationModel = await DBModule.runJob("GET_MODEL", { modelName: "station" }));
 		const stationSchema = (this.stationSchema = await CacheModule.runJob("GET_SCHEMA", { schemaName: "station" }));
 
-		const stationHistoryModel = (this.stationHistoryModel = await DBModule.runJob("GET_MODEL", {
+		this.stationHistoryModel = await DBModule.runJob("GET_MODEL", {
 			modelName: "stationHistory"
-		}));
+		});
 
 		return new Promise((resolve, reject) => {
 			async.waterfall(

+ 1 - 1
frontend/src/classes/SocketHandler.class.ts

@@ -123,7 +123,7 @@ export default class SocketHandler {
 		if (this.firstInit) {
 			this.firstInit = false;
 			this.on("ready", data => {
-				console.log("WS: SOCKET READY", data);
+				console.log("WS: SOCKET READY");
 
 				configStore.$patch(data.config);
 

+ 0 - 1
frontend/src/pages/Admin/Songs/Import.vue

@@ -346,7 +346,6 @@ const editSongs = youtubeIds => {
 	const mediaSources = youtubeIds.map(youtubeId => ({
 		mediaSource: `youtube:${youtubeId}`
 	}));
-	console.log(59685486, youtubeIds, mediaSources);
 	if (mediaSources.length === 1)
 		openModal({ modal: "editSong", props: { song: mediaSources[0] } });
 	else openModal({ modal: "editSong", props: { songs: mediaSources } });

+ 0 - 1
frontend/src/pages/Admin/YouTube/Videos.vue

@@ -252,7 +252,6 @@ const importAlbum = selectedRows => {
 	const mediaSources = selectedRows.map(
 		({ youtubeId }) => `youtube:${youtubeId}`
 	);
-	console.log(77988, mediaSources);
 	socket.dispatch("songs.getSongsFromMediaSources", mediaSources, res => {
 		if (res.status === "success") {
 			openModal({

+ 0 - 1
frontend/src/stores/editSong.ts

@@ -67,7 +67,6 @@ export const useEditSongStore = ({ modalUuid }: { modalUuid: string }) =>
 		}),
 		actions: {
 			init({ song, songs }) {
-				console.log(12357878, song, songs);
 				if (songs) {
 					this.bulk = true;
 					this.mediaSources = songs.map(song => song.mediaSource);