瀏覽代碼

Cleaned up Johand's code.

KrisVos130 9 年之前
父節點
當前提交
3fd0194eed
共有 1 個文件被更改,包括 9 次插入17 次删除
  1. 9 17
      app/server/server.js

+ 9 - 17
app/server/server.js

@@ -432,31 +432,23 @@ Meteor.methods({
             var rawrank = user.profile.rank;
             var username = user.profile.username;
             var rank = user.profile.rank;
-            if (user.profile.rank = "admin") {
-            if (message.length === 0) {
-                throw new Meteor.Error(406, "Message length cannot be 0.");
-            }
-                Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username});
-                return true;
-            }
-            if (user.profile.rank = "mod") {
-            if (message.length === 0) {
-                throw new Meteor.Error(406, "Message length cannot be 0.");
-            }
-                Chat.insert({type: type, rank: "[M]", message: message, time: time, username: username});
-                return true;
-            }
             if (message.length === 0) {
                 throw new Meteor.Error(406, "Message length cannot be 0.");
             }
             if (message.length > 300) {
                 throw new Meteor.Error(406, "Message length cannot be more than 300 characters long..");
             }
+            if (user.profile.rank = "admin") {
+                Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username, rank: rank});
+                return true;
+            } else if (user.profile.rank = "mod") {
+                Chat.insert({type: type, rank: "[M]", message: message, time: time, username: username, rank: rank});
+                return true;
+            }
             else {
-            Chat.insert({type: type, rank: "", message: message, time: time, username: username});
-            return true;
+                Chat.insert({type: type, rank: "", message: message, time: time, username: username, rank: rank});
+                return true;
             }
-           
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");
         }