Преглед изворни кода

Fixed unlisted stations showing for non-logged in users on homepage

Kristian Vos пре 4 година
родитељ
комит
fbe7e27dd8
2 измењених фајлова са 8 додато и 9 уклоњено
  1. 1 7
      backend/logic/actions/stations.js
  2. 7 2
      backend/logic/stations.js

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

@@ -391,7 +391,6 @@ module.exports = {
         async.waterfall(
             [
                 (next) => {
-                    console.log(111);
                     cache
                         .runJob("HGETALL", { table: "stations" })
                         .then((stations) => {
@@ -400,8 +399,6 @@ module.exports = {
                 },
 
                 (stations, next) => {
-                    console.log(222);
-
                     let resultStations = [];
                     for (let id in stations) {
                         resultStations.push(stations[id]);
@@ -410,8 +407,6 @@ module.exports = {
                 },
 
                 (stationsArray, next) => {
-                    console.log(333);
-
                     let resultStations = [];
                     async.each(
                         stationsArray,
@@ -423,10 +418,9 @@ module.exports = {
                                             .runJob("CAN_USER_VIEW_STATION", {
                                                 station,
                                                 userId: session.userId,
+                                                hideUnlisted: true
                                             })
                                             .then((exists) => {
-                                                console.log(444, exists);
-
                                                 next(null, exists);
                                             })
                                             .catch(next);

+ 7 - 2
backend/logic/stations.js

@@ -1119,13 +1119,18 @@ class StationsModule extends CoreClass {
     }
 
     CAN_USER_VIEW_STATION(payload) {
-        // station, userId, cb
+        // station, userId, hideUnlisted, cb
         return new Promise((resolve, reject) => {
             async.waterfall(
                 [
                     (next) => {
-                        if (payload.station.privacy !== "private")
+                        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.userId) return next("Not allowed");
                         next();
                     },