- The `mode` should be either "development" or "production". No more explanation needed.
- The `secret` key can be whatever. It's used by express's session module.
- The `domain` should be the url where the site will be accessible from, usually `http://localhost` for non-Docker.
- The `serverDomain` should be the url where the backend will be accessible from, usually `http://localhost:8080` for non-Docker.
- The `serverPort` should be the port where the backend will listen on, should always be `8080` for Docker, and is recommended for non-Docker.
- `isDocker` if you are using Docker or not.
- The `apis.youtube.key` value can be obtained by setting up a [YouTube API Key](https://developers.google.com/youtube/v3/getting-started). You need to use the YouTube Data API v3, and create an API key.
- The `apis.recaptcha.secret` value can be obtained by setting up a [ReCaptcha Site (v3)](https://www.google.com/recaptcha/admin).
- The `apis.github` values can be obtained by setting up a [GitHub OAuth Application](https://github.com/settings/developers). You need to fill in some values to create the OAuth application. The homepage is the homepage of frontend. The authorization callback url is the backend url with `/auth/github/authorize/callback` added at the end. For example `http://localhost:8080/auth/github/authorize/callback`.
- The `apis.discord.token` is the token for the Discord bot.
- The `apis.discord.loggingServer` is the Discord logging server id.
- The `apis.discord.loggingChannel` is the Discord logging channel id.
- The `apis.mailgun` values can be obtained by setting up a [Mailgun account](http://www.mailgun.com/), or you can disable it.
- The `apis.spotify` values can be obtained by setting up a [Spotify client id](https://developer.spotify.com/dashboard/applications), or you can disable it.
- The `redis.url` url should be left alone for Docker, and changed to `redis://localhost:6379/0` for non-Docker.
- The `redis.password` should be the Redis password you either put in your `startRedis.cmd` file for Windows, or `.env` for docker.
- The `mongo.url` needs to have the proper password for the MongoDB musare user, and for non-Docker you need to replace `@musare:27017` with `@localhost:27017`.
- The `cookie.domain` value should be the ip or address you use to access the site, without protocols (http/https), so for example `localhost`.
- The `cookie.secure` value should be `true` for SSL connections, and `false` for normal http connections.
+|Property|Description|
+|--|--|
+|`mode`|Should be either `development` or `production`. No more explanation needed.|
+|`secret`|Whatever you want - used by express's session module.|
+|`domain`|Should be the url where the site will be accessible from,usually `http://localhost` for non-Docker.|
+|`serverDomain`|Should be the url where the backend will be accessible from, usually `http://localhost:8080` for non-Docker.|
+|`serverPort`|Should be the port where the backend will listen on, should always be `8080` for Docker, and is recommended for non-Docker.|
+|`isDocker`|Self-explanatory. Are you using Docker?|
+|`serverPort`|Should be the port where the backend will listen on, should always be `8080` for Docker, and is recommended for non-Docker.|
+|`apis.youtube.key`|Can be obtained by setting up a [YouTube API Key](https://developers.google.com/youtube/v3/getting-started). You need to use the YouTube Data API v3, and create an API key.|
+|`apis.recaptcha.secret`|Can be obtained by setting up a [ReCaptcha Site (v3)](https://www.google.com/recaptcha/admin).|
+|`apis.github`|Can be obtained by setting up a [GitHub OAuth Application](https://github.com/settings/developers). You need to fill in some values to create the OAuth application. The homepage is the homepage of frontend. The authorization callback url is the backend url with `/auth/github/authorize/callback` added at the end. For example `http://localhost:8080/auth/github/authorize/callback`.|
+|`apis.discord.token`|Token for the Discord bot.|
+|`apis.discord.loggingServer`|Server ID of the Discord logging server.|
+|`apis.discord.loggingChannel`|ID of the channel to be used in the Discord logging server.|
+|`apis.mailgun`|Can be obtained by setting up a [Mailgun account](http://www.mailgun.com/), or you can disable it.|
+|`apis.spotify`|Can be obtained by setting up a [Spotify client id](https://developer.spotify.com/dashboard/applications), or you can disable it.|
+|`apis.discogs`|Can be obtained by setting up a [Discogs application](https://www.discogs.com/settings/developers), or you can disable it.|
+|`redis.url`|Should be left alone for Docker, and changed to `redis://localhost:6379/0` for non-Docker.|
+|`redis.password`|Should be the Redis password you either put in your `startRedis.cmd` file for Windows, or `.env` for docker.|
+|`mongo.url`|Needs to have the proper password for the MongoDB musare user, and for non-Docker you need to replace `@musare:27017` with `@localhost:27017`.|
+|`cookie.domain`|Should be 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.|
- The `serverDomain` should be the url where the backend will be accessible from, usually `http://localhost:8080` for non-Docker.
- The `frontendDomain` should be the url where the frontend will be accessible from, usually `http://localhost` for docker or `http://localhost:80` for non-Docker.
- The `frontendPort` should be the port where the frontend will be accessible from, should always be port `81` for Docker, and is recommended to be port `80` for non-Docker.
- The `recaptcha.key` value can be obtained by setting up a [ReCaptcha Site (v3)](https://www.google.com/recaptcha/admin).
- The `cookie.domain` value should be the ip or address you use to access the site, without protocols (http/https), so for example `localhost`.
- The `cookie.secure` value should be `true` for SSL connections, and `false` for normal http connections.
- The `siteSettings.logo` should be the path to the logo image, by default it is `/assets/wordmark.png`.
- The `siteSettings.siteName` should be the name of the site.
- The `siteSettings.socialLinks.` `github`,`twitter`,`facebook` and `github` are set to the official Musare accounts by default but can be changed.
+|Property|Description|
+|--|--|
+|`serverDomain`|Should be the url where the backend will be accessible from, usually `http://localhost:8080` for non-Docker.|
+|`frontendDomain`|Should be the url where the frontend will be accessible from, usually `http://localhost` for docker or `http://localhost:80` for non-Docker.|
+|`frontendPort`|Should be the port where the frontend will be accessible from, should always be port `81` for Docker, and is recommended to be port `80` for non-Docker.|
+|`recaptcha.key`|Can be obtained by setting up a [ReCaptcha Site (v3)](https://www.google.com/recaptcha/admin).|
+|`cookie.domain`|Should be 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.|
+|`siteSettings.logo`|Path to the logo image, by default it is `/assets/wordmark.png`.|
+|`siteSettings.siteName`|Should be the name of the site.|
+|`siteSettings.socialLinks`|`github`, `twitter` and `facebook` are set to the official Musare accounts by default, but can be changed.|
-Now you have different paths here.
+5. Simply `cp .env.example .env` to setup your environment variables.
+
+6. To setup [snyk](https://snyk.io/) (which is what we use for our precommit git-hooks), you will need to:
+- Setup an account
+- Go to [settings](https://app.snyk.io/account)
+- Copy the API token and set it as your `SNYK_TOKEN` environment variable.
+
+We use snyk to test our dependencies / dev-dependencies for vulnerabilities.
### Installing with Docker
### Installing with Docker
_Configuration_
_Configuration_
-To configure docker simply `cp .env.example .env` and configure the .env file to match your settings in `backend/config/default.json`.
+To configure docker configure the `.env` file to match your settings in `backend/config/default.json`.
The configurable ports will be how you access the services on your machine, or what ports you will need to specify in your nginx files when using proxy_pass.
The configurable ports will be how you access the services on your machine, or what ports you will need to specify in your nginx files when using proxy_pass.
`COMPOSE_PROJECT_NAME` should be a unique name for this installation, especially if you have multiple instances of Musare on the same machine.
`COMPOSE_PROJECT_NAME` should be a unique name for this installation, especially if you have multiple instances of Musare on the same machine.
`FRONTEND_MODE` should be either `dev` or `prod` (self-explanatory).
`FRONTEND_MODE` should be either `dev` or `prod` (self-explanatory).
@@ -268,9 +280,9 @@ Run this command in your shell. You will have to do this command for every shell
`yarn global add node-gyp`.
`yarn global add node-gyp`.
-5. In both `frontend` and `backend` folders, do `yarn install`.
+5. Run `yarn run bootstrap` to install dependencies and dev-dependencies for both the frontend and backend.
-6. `nodemon backend/index.js`
+6. Either execute `yarn run dev:frontend` and `yarn run dev:backend` separately, or in parallel with `yarn dev`.
- discord.sendAdminAlertMessage(message, "#FF0000", message, true, [{name: "Error:", value: err, inline: false}, {name: "Component:", value: component, inline: true}]); //TODO Maybe due to lockdown this won't work, and what if the Discord module was the one that failed?
-}
+ addModule(moduleName) {
+ console.log("add module", moduleName);
+ const moduleClass = new require(`./logic/${moduleName}`);
+ this.modules[moduleName] = new moduleClass(moduleName, this);
+ this.totalModules++;
+ this.modulesLeft.push(moduleName);
+ }
-function moduleStartFunction() {
- logger.info("MODULE_START", `Starting to initialize component '${currentComponent}'`);
-}
+ initialize() {
+ if (!this.modules["logger"]) return console.error("There is no logger module");
+ if (this.modulesLeft.length === 0) this.allModulesInitialized();
+ }
+
+ allModulesInitialized() {
+ this.logger.success("MODULE_MANAGER", "All modules have started!");
+ this.modules["discord"].sendAdminAlertMessage("The backend server started successfully.", "#00AA00", "Startup", false, []);
+ }
+
+ aModuleFailed(failedModule) {
+ this.logger.error("MODULE_MANAGER", `A module has failed, locking down. Module: ${failedModule.name}`);
+ this.modules["discord"].sendAdminAlertMessage(`The backend server failed to start due to a failing module: ${failedModule.name}.`, "#AA0000", "Startup", false, []);
logger.error("PLAYLIST_INDEX_FOR_USER", `Indexing playlists for user "${userId}" failed. "${err}"`);
logger.error("PLAYLIST_INDEX_FOR_USER", `Indexing playlists for user "${userId}" failed. "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
}
}
@@ -155,9 +157,9 @@ let lib = {
}, next);
}, next);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_CREATE", `Creating private playlist failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_CREATE", `Creating private playlist failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
}
}
@@ -187,9 +189,9 @@ let lib = {
if (!playlist || playlist.createdBy !== userId) return next('Playlist not found');
if (!playlist || playlist.createdBy !== userId) return next('Playlist not found');
next(null, playlist);
next(null, playlist);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_GET", `Getting private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_GET", `Getting private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
}
}
@@ -220,9 +222,9 @@ let lib = {
(res, next) => {
(res, next) => {
playlists.updatePlaylist(playlistId, next)
playlists.updatePlaylist(playlistId, next)
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_UPDATE", `Updating private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_UPDATE", `Updating private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
}
}
@@ -280,9 +282,9 @@ let lib = {
});
});
}
}
],
],
- (err, playlist, newSong) => {
+ async (err, playlist, newSong) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_ADD_SONG", `Adding song "${songId}" to private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_ADD_SONG", `Adding song "${songId}" to private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
} else {
} else {
@@ -329,9 +331,9 @@ let lib = {
if (!playlist || playlist.createdBy !== userId) return next('Playlist not found.');
if (!playlist || playlist.createdBy !== userId) return next('Playlist not found.');
next(null, playlist);
next(null, playlist);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_IMPORT", `Importing a YouTube playlist to private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_IMPORT", `Importing a YouTube playlist to private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
} else {
} else {
@@ -370,9 +372,9 @@ let lib = {
(res, next) => {
(res, next) => {
playlists.updatePlaylist(playlistId, next);
playlists.updatePlaylist(playlistId, next);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_REMOVE_SONG", `Removing song "${songId}" from private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_REMOVE_SONG", `Removing song "${songId}" from private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
} else {
} else {
@@ -400,9 +402,9 @@ let lib = {
(res, next) => {
(res, next) => {
playlists.updatePlaylist(playlistId, next);
playlists.updatePlaylist(playlistId, next);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_UPDATE_DISPLAY_NAME", `Updating display name to "${displayName}" for private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_UPDATE_DISPLAY_NAME", `Updating display name to "${displayName}" for private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
}
}
@@ -459,9 +461,9 @@ let lib = {
(res, next) => {
(res, next) => {
playlists.updatePlaylist(playlistId, next);
playlists.updatePlaylist(playlistId, next);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_MOVE_SONG_TO_TOP", `Moving song "${songId}" to the top for private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_MOVE_SONG_TO_TOP", `Moving song "${songId}" to the top for private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
}
}
@@ -515,9 +517,9 @@ let lib = {
(res, next) => {
(res, next) => {
playlists.updatePlaylist(playlistId, next);
playlists.updatePlaylist(playlistId, next);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_MOVE_SONG_TO_BOTTOM", `Moving song "${songId}" to the bottom for private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_MOVE_SONG_TO_BOTTOM", `Moving song "${songId}" to the bottom for private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
return cb({ status: 'failure', message: err});
return cb({ status: 'failure', message: err});
}
}
@@ -540,9 +542,9 @@ let lib = {
(next) => {
(next) => {
playlists.deletePlaylist(playlistId, next);
playlists.deletePlaylist(playlistId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("PLAYLIST_REMOVE", `Removing private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("PLAYLIST_REMOVE", `Removing private playlist "${playlistId}" failed for user "${userId}". "${err}"`);
logger.error("STATIONS_FIND_BY_NAME", `Finding station "${stationName}" failed. "${err}"`);
logger.error("STATIONS_FIND_BY_NAME", `Finding station "${stationName}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -307,9 +311,9 @@ module.exports = {
if (!playlist) return next('Playlist not found.');
if (!playlist) return next('Playlist not found.');
next(null, playlist);
next(null, playlist);
}
}
- ], (err, playlist) => {
+ ], async (err, playlist) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_GET_PLAYLIST", `Getting playlist for station "${stationId}" failed. "${err}"`);
logger.error("STATIONS_GET_PLAYLIST", `Getting playlist for station "${stationId}" failed. "${err}"`);
return cb({ status: 'failure', message: err });
return cb({ status: 'failure', message: err });
} else {
} else {
@@ -353,9 +357,9 @@ module.exports = {
if (station.owner === session.userId) return next(true);
if (station.owner === session.userId) return next(true);
next('An error occurred while joining the station.');
next('An error occurred while joining the station.');
}
}
- ], (err) => {
+ ], async (err) => {
if (err === true) return next(null, station);
if (err === true) return next(null, station);
- next(utils.getError(err));
+ next(await utils.getError(err));
});
});
},
},
@@ -398,9 +402,9 @@ module.exports = {
next(null, data);
next(null, data);
});
});
}
}
- ], (err, data) => {
+ ], async (err, data) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_JOIN", `Joining station "${stationName}" failed. "${err}"`);
logger.error("STATIONS_JOIN", `Joining station "${stationName}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -429,9 +433,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err, station) => {
+ ], async (err, station) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_LOCKED_STATUS", `Toggling the queue lock for station "${stationId}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_LOCKED_STATUS", `Toggling the queue lock for station "${stationId}" failed. "${err}"`);
return cb({ status: 'failure', message: err });
return cb({ status: 'failure', message: err });
} else {
} else {
@@ -482,9 +486,9 @@ module.exports = {
if (!station) return next('Station not found.');
if (!station) return next('Station not found.');
next(null, station);
next(null, station);
}
}
- ], (err, station) => {
+ ], async (err, station) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_VOTE_SKIP", `Vote skipping station "${stationId}" failed. "${err}"`);
logger.error("STATIONS_VOTE_SKIP", `Vote skipping station "${stationId}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -512,9 +516,9 @@ module.exports = {
if (!station) return next('Station not found.');
if (!station) return next('Station not found.');
next();
next();
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_FORCE_SKIP", `Force skipping station "${stationId}" failed. "${err}"`);
logger.error("STATIONS_FORCE_SKIP", `Force skipping station "${stationId}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -543,9 +547,9 @@ module.exports = {
if (!station) return next('Station not found.');
if (!station) return next('Station not found.');
next();
next();
}
}
- ], (err, userCount) => {
+ ], async (err, userCount) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_LEAVE", `Leaving station "${stationId}" failed. "${err}"`);
logger.error("STATIONS_LEAVE", `Leaving station "${stationId}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -573,9 +577,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_DISPLAY_NAME", `Updating station "${stationId}" displayName to "${newName}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_DISPLAY_NAME", `Updating station "${stationId}" displayName to "${newName}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -601,9 +605,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_DISPLAY_NAME", `Updating station "${stationId}" displayName to "${newDisplayName}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_DISPLAY_NAME", `Updating station "${stationId}" displayName to "${newDisplayName}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -629,9 +633,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_DESCRIPTION", `Updating station "${stationId}" description to "${newDescription}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_DESCRIPTION", `Updating station "${stationId}" description to "${newDescription}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -657,9 +661,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_PRIVACY", `Updating station "${stationId}" privacy to "${newPrivacy}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_PRIVACY", `Updating station "${stationId}" privacy to "${newPrivacy}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -685,9 +689,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_GENRES", `Updating station "${stationId}" genres to "${newGenres}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_GENRES", `Updating station "${stationId}" genres to "${newGenres}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -713,9 +717,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_BLACKLISTED_GENRES", `Updating station "${stationId}" blacklisted genres to "${newBlacklistedGenres}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_BLACKLISTED_GENRES", `Updating station "${stationId}" blacklisted genres to "${newBlacklistedGenres}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -747,9 +751,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_UPDATE_PARTY_MODE", `Updating station "${stationId}" party mode to "${newPartyMode}" failed. "${err}"`);
logger.error("STATIONS_UPDATE_PARTY_MODE", `Updating station "${stationId}" party mode to "${newPartyMode}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -782,9 +786,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_PAUSE", `Pausing station "${stationId}" failed. "${err}"`);
logger.error("STATIONS_PAUSE", `Pausing station "${stationId}" failed. "${err}"`);
return cb({'status': 'failure', 'message': err});
return cb({'status': 'failure', 'message': err});
}
}
@@ -818,9 +822,9 @@ module.exports = {
(res, next) => {
(res, next) => {
stations.updateStation(stationId, next);
stations.updateStation(stationId, next);
}
}
- ], (err) => {
+ ], async (err) => {
if (err) {
if (err) {
- err = utils.getError(err);
+ err = await utils.getError(err);
logger.error("STATIONS_RESUME", `Resuming station "${stationId}" failed. "${err}"`);
logger.error("STATIONS_RESUME", `Resuming station "${stationId}" failed. "${err}"`);
- //TODO Check every 30s/60s, for all sockets, if they are still allowed to be in the rooms they are in, and on socket at all (permission changing/banning)
- this.io = require('socket.io')(app.server);
+ initialize() {
+ return new Promise(resolve => {
+ this.setStage(1);
- this.io.use((socket, next) => {
- if (lockdown) return;
- let cookies = socket.request.headers.cookie;
- let SID = utils.cookies.parseCookies(cookies).SID;
+ // TODO: Check every 30s/60s, for all sockets, if they are still allowed to be in the rooms they are in, and on socket at all (permission changing/banning)
if (station.type === 'community' && station.partyMode && station.queue.length === 0) return next(null, null, -11, station); // Community station with party mode enabled and no songs in the queue
if (station.type === 'community' && station.partyMode && station.queue.length === 0) return next(null, null, -11, station); // Community station with party mode enabled and no songs in the queue
if (station.type === 'community' && station.partyMode && station.queue.length > 0) { // Community station with party mode enabled and songs in the queue
if (station.type === 'community' && station.partyMode && station.queue.length > 0) { // Community station with party mode enabled and songs in the queue
+ this.logger.info("TASK_SESSION_CLEAR", `Removing session ${sessionId} for user ${session.userId} since inactive for 30 days and not currently in use.`);