ソースを参照

refactor(Home): Don't display unlisted stations unless owned by user

Owen Diffey 3 年 前
コミット
11049910e9
2 ファイル変更4 行追加6 行削除
  1. 1 1
      backend/logic/actions/stations.js
  2. 3 5
      backend/logic/stations.js

+ 1 - 1
backend/logic/actions/stations.js

@@ -602,7 +602,7 @@ export default {
 											{
 												station,
 												userId: session.userId,
-												hideUnlisted: true
+												homeView: true
 											},
 											this
 										)

+ 3 - 5
backend/logic/stations.js

@@ -984,7 +984,7 @@ class _StationsModule extends CoreClass {
 	 * @param {object} payload - object that contains the payload
 	 * @param {object} payload.station - the station object of the station in question
 	 * @param {string} payload.userId - the id of the user in question
-	 * @param {boolean} payload.hideUnlisted - whether the user is allowed to see unlisted stations or not
+	 * @param {boolean} payload.homeView - whether to modify output for homepage usage
 	 * @returns {Promise} - returns a promise (resolve, reject)
 	 */
 	CAN_USER_VIEW_STATION(payload) {
@@ -993,9 +993,7 @@ class _StationsModule extends CoreClass {
 				[
 					next => {
 						if (payload.station.privacy === "public") return next(true);
-						if (payload.station.privacy === "unlisted")
-							if (payload.hideUnlisted === true) return next();
-							else return next(true);
+						if (payload.station.privacy === "unlisted" && !payload.homeView) return next(true);
 						if (!payload.userId) return next("Not allowed");
 
 						return next();
@@ -1009,7 +1007,7 @@ class _StationsModule extends CoreClass {
 
 					(user, next) => {
 						if (!user) return next("Not allowed");
-						if (user.role === "admin") return next(true);
+						if (!payload.homeView && user.role === "admin") return next(true);
 						if (payload.station.type === "official") return next("Not allowed");
 						if (payload.station.owner === payload.userId) return next(true);