浏览代码

Fixed issue where you couldn't visit unlisted rooms.

KrisVos130 9 年之前
父节点
当前提交
cc4985b3bc
共有 4 个文件被更改,包括 26 次插入8 次删除
  1. 1 1
      app/client/scripts/helpers.js
  2. 1 1
      app/client/scripts/onCreated.js
  3. 9 6
      app/client/scripts/routes.js
  4. 15 0
      app/server/server.js

+ 1 - 1
app/client/scripts/helpers.js

@@ -595,7 +595,7 @@ Template.communityStation.helpers({
     },
     allowed: function () {
         var parts = location.href.split('/');
-        var id = parts.pop().toLowerCase();deploy
+        var id = parts.pop().toLowerCase();
         var arr = [];
         CommunityStations.findOne({name: id}).allowed.forEach(function(allowed) {
             arr.push({name: Meteor.users.findOne(allowed).profile.username, id: allowed});

+ 1 - 1
app/client/scripts/onCreated.js

@@ -475,7 +475,7 @@ Template.communityStation.onCreated(function () {
                                         function recursion() {
                                             Meteor.setTimeout(function() {
                                                 if (event.target.getPlayerState() === 1 && Session.get("state") === "playing") {
-                                                    event.target.seekTo(Number(currentSong.skipDuration) + getTimeElapsed() / 1000);
+                                                    event.target.seekTo(getTimeElapsed() / 1000);
                                                 } else {
                                                     recursion();
                                                 }

+ 9 - 6
app/client/scripts/routes.js

@@ -187,18 +187,21 @@ Router.route("/u/:user", {
 
 Router.route("/community/:name", {
     waitOn: function() {
-        return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId()), Meteor.subscribe("community_stations")];
+        return [Meteor.subscribe("isModerator", Meteor.userId()), Meteor.subscribe("isAdmin", Meteor.userId()), Meteor.subscribe("community_station", this.params.name)];
     },
     action: function() {
         var user = Meteor.users.findOne({});
         var room = CommunityStations.findOne({name: this.params.name});
         if (room !== undefined) {
             if (
-                (room.privacy === "private" && user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) ||
-                (user !== undefined && user.profile !== undefined && room.allowed.includes(Meteor.userId())) ||
-                room.privacy !== "private" ||
-                room.owner === Meteor.userId()) {
-                Session.set("type", this.params.type);
+                (room !== undefined)
+                    &&
+                (
+                    (room.privacy === "private" && user !== undefined && user.profile !== undefined && (user.profile.rank === "admin" || user.profile.rank === "moderator")) ||
+                    (user !== undefined && user.profile !== undefined && room.allowed.includes(Meteor.userId())) ||
+                    room.privacy !== "private" ||
+                    room.owner === Meteor.userId())
+                ) {
                 this.render("communityStation");
             } else {
                 this.redirect("/");

+ 15 - 0
app/server/server.js

@@ -773,6 +773,21 @@ Meteor.publish("community_stations", function () {
     }
 });
 
+Meteor.publish("community_station", function (name) {
+    var userId = this.userId;
+    if (userId) {
+        var user = Meteor.users.findOne(userId);
+        if (user.profile.rank === "admin" || user.profile.rank === "moderator") {
+            return CommunityStations.find({name: name});
+        } else {
+            return CommunityStations.find({name: name, $or: [{owner: userId}, {privacy: "public"}]});
+        }
+    } else {
+        return CommunityStations.find({name: name, $or: [{privacy: "public"}, {privacy: "unlisted"}]});
+    }
+});
+
+
 Meteor.publish("private_playlists", function () {
     if (this.userId !== undefined) {
         return PrivatePlaylists.find({owner: this.userId});