Переглянути джерело

Merge branch 'odiffey-owen-fixes' into polishing

Kristian Vos 3 роки тому
батько
коміт
0357b222c5

+ 1 - 0
.wiki/Configuration.md

@@ -27,6 +27,7 @@ Location: `backend/config/default.json`
 | `apis.discogs.client` | Discogs Application client, obtained from [here](https://www.discogs.com/settings/developers). |
 | `apis.discogs.secret` | Discogs Application secret, obtained with client. |
 | `apis.discogs.enabled` | Whether to enable Discogs API usage. |
+| `cors.origin` | Array of allowed request origin urls, for example `http://localhost`. |
 | `smtp.host` | SMTP Host |
 | `smtp.port` | SMTP Port |
 | `smtp.auth.user` | SMTP Username |

+ 5 - 0
backend/config/template.json

@@ -32,6 +32,11 @@
 			"enabled": false
 		}
 	},
+	"cors": {
+		"origin": [
+			"http://localhost"
+		]
+	},
 	"smtp": {
 		"host": "smtp.mailgun.org",
 		"port": 587,

+ 4 - 4
backend/logic/actions/playlists.js

@@ -1370,7 +1370,7 @@ export default {
 				},
 
 				(playlist, next) => {
-					if (playlist.createdBy !== session.userId) return next("You do not own this playlist."); 
+					if (playlist.createdBy !== session.userId) return next("You do not own this playlist.");
 					if (!playlist.isUserModifiable) return next("Playlist cannot be removed.");
 					return next(null, playlist);
 				},
@@ -1439,7 +1439,7 @@ export default {
 	 * @param {string} playlistId - the id of the playlist we are removing
 	 * @param {Function} cb - gets called with the result
 	 */
-	 removeAdmin: isAdminRequired(async function removeAdmin(session, playlistId, cb) {
+	removeAdmin: isAdminRequired(async function removeAdmin(session, playlistId, cb) {
 		const userModel = await DBModule.runJob("GET_MODEL", { modelName: "user" }, this);
 
 		async.waterfall(
@@ -1501,8 +1501,8 @@ export default {
 					message: "Playlist successfully removed"
 				});
 			}
-		)
-	 }),
+		);
+	}),
 
 	/**
 	 * Updates the privacy of a private playlist

+ 5 - 4
backend/logic/playlists.js

@@ -950,10 +950,11 @@ class _PlaylistsModule extends CoreClass {
 							"REMOVE_INCLUDED_OR_EXCLUDED_PLAYLIST_FROM_STATIONS",
 							{ playlistId: payload.playlistId },
 							this
-						).then(() => {
-							next();
-						})
-						.catch(err => next(err));
+						)
+							.then(() => {
+								next();
+							})
+							.catch(err => next(err));
 					}
 				],
 				err => {

+ 3 - 2
backend/logic/songs.js

@@ -615,9 +615,10 @@ class _SongsModule extends CoreClass {
 
 						let { query } = payload;
 
-						const isRegex = query.length > 2 && query.indexOf("/") === 0 && query.lastIndexOf("/") === query.length - 1;
+						const isRegex =
+							query.length > 2 && query.indexOf("/") === 0 && query.lastIndexOf("/") === query.length - 1;
 						if (isRegex) query = query.slice(1, query.length - 1);
-						else query = query.replaceAll(/[.*+?^${}()|[\]\\]/g, '\\$&');
+						else query = query.replaceAll(/[.*+?^${}()|[\]\\]/g, "\\$&");
 
 						const filterArray = [
 							{

+ 5 - 2
backend/logic/stations.js

@@ -1522,7 +1522,10 @@ class _StationsModule extends CoreClass {
 					next => {
 						StationsModule.stationModel.updateMany(
 							{
-								$or: [{ includedPlaylists: payload.playlistId }, { excludedPlaylists: payload.playlistId }]
+								$or: [
+									{ includedPlaylists: payload.playlistId },
+									{ excludedPlaylists: payload.playlistId }
+								]
 							},
 							{
 								$pull: {
@@ -1530,7 +1533,7 @@ class _StationsModule extends CoreClass {
 									excludedPlaylists: payload.playlistId
 								}
 							},
-							(err) => {
+							err => {
 								if (err) next(err);
 								else next();
 							}