Selaa lähdekoodia

Read commit description

Mods and admins can now bypass chat limit, they also got a different
chat layout
Johand 9 vuotta sitten
vanhempi
sitoutus
21c32094ec
3 muutettua tiedostoa jossa 29 lisäystä ja 5 poistoa
  1. 9 3
      app/client/app.css
  2. 1 1
      app/client/templates/room.html
  3. 19 1
      app/server/server.js

+ 9 - 3
app/client/app.css

@@ -1189,9 +1189,15 @@ nav form input[type="image"]{
     padding-left: 15px;
     padding-right: 15px;
 }
-.chat-rank {
-    color: white;
-    font-size: 10px;
+.rank-admin {
+    color: crimson;
+    font-size: 20px;
+    font-weight: bold;
+}
+.rank-mod {
+    color: darkgoldenrod;
+    font-size: 20px;
+    font-weight: bold;
 }
 .row {
     margin: 0;

+ 1 - 1
app/client/templates/room.html

@@ -101,7 +101,7 @@
                         <div class="tab-pane" id="chat">
                             <ul id="chat-ul">
                                 {{#each chat}}
-                                    <li class="chat-message"><small class="chat-rank">[{{this.rank}}]</small> <a style="text-decoration: none" href="/u/{{this.username}}" target="_blank"><b class="bold">{{this.username}}</b></a>: {{this.message}}</li>
+                                    <li class="chat-message"><small class="rank-{{this.rawrank}}">{{this.rank}}</small> <a style="text-decoration: none" href="/u/{{this.username}}" target="_blank"><b class="bold">{{this.username}}</b></a>: {{this.message}}</li>
                                     <hr>
                                 {{/each}}
                             </ul>

+ 19 - 1
app/server/server.js

@@ -429,16 +429,34 @@ Meteor.methods({
         if (Meteor.userId()) {
             var user = Meteor.user();
             var time = new Date();
+            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..");
             }
-            Chat.insert({type: type, rank: rank, message: message, time: time, username: username});
+            else {
+            Chat.insert({type: type, rank: "", message: message, time: time, username: username});
             return true;
+            }
+           
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");
         }