|
@@ -413,6 +413,10 @@ Meteor.publish("isAdmin", function() {
|
|
return Meteor.users.find({_id: this.userId, "profile.rank": "admin"});
|
|
return Meteor.users.find({_id: this.userId, "profile.rank": "admin"});
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+Meteor.publish("isModerator", function() {
|
|
|
|
+ return Meteor.users.find({_id: this.userId, "profile.rank": "moderator"});
|
|
|
|
+});
|
|
|
|
+
|
|
function isAdmin() {
|
|
function isAdmin() {
|
|
var userData = Meteor.users.find(Meteor.userId());
|
|
var userData = Meteor.users.find(Meteor.userId());
|
|
if (Meteor.userId() && userData.count !== 0 && userData.fetch()[0].profile.rank === "admin") {
|
|
if (Meteor.userId() && userData.count !== 0 && userData.fetch()[0].profile.rank === "admin") {
|
|
@@ -422,6 +426,15 @@ function isAdmin() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function isModerator() {
|
|
|
|
+ var userData = Meteor.users.find(Meteor.userId());
|
|
|
|
+ if (Meteor.userId() && userData.count !== 0 && userData.fetch()[0].profile.rank === "moderator") {
|
|
|
|
+ return true;
|
|
|
|
+ } else {
|
|
|
|
+ return isAdmin();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
function isBanned() {
|
|
function isBanned() {
|
|
var userData = Meteor.users.findOne(Meteor.userId());
|
|
var userData = Meteor.users.findOne(Meteor.userId());
|
|
if (Meteor.userId() && userData !== undefined && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
|
|
if (Meteor.userId() && userData !== undefined && userData.punishments !== undefined && userData.punishments.ban !== undefined) {
|
|
@@ -529,7 +542,7 @@ Meteor.methods({
|
|
Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username});
|
|
Chat.insert({type: type, rawrank: rawrank, rank: "[A]", message: message, time: time, username: username});
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- else if (user.profile.rank === "mod") {
|
|
|
|
|
|
+ else if (user.profile.rank === "moderator") {
|
|
Chat.insert({type: type, rawrank: rawrank, rank: "[M]", message: message, time: time, username: username});
|
|
Chat.insert({type: type, rawrank: rawrank, rank: "[M]", message: message, time: time, username: username});
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -715,7 +728,7 @@ Meteor.methods({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
updateQueueSong: function(genre, oldSong, newSong) {
|
|
updateQueueSong: function(genre, oldSong, newSong) {
|
|
- if (isAdmin() && !isBanned()) {
|
|
|
|
|
|
+ if (isModerator() && !isBanned()) {
|
|
newSong.mid = oldSong.mid;
|
|
newSong.mid = oldSong.mid;
|
|
Queues.update({type: genre, "songs": oldSong}, {$set: {"songs.$": newSong}});
|
|
Queues.update({type: genre, "songs": oldSong}, {$set: {"songs.$": newSong}});
|
|
return true;
|
|
return true;
|
|
@@ -724,7 +737,7 @@ Meteor.methods({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
updatePlaylistSong: function(genre, oldSong, newSong) {
|
|
updatePlaylistSong: function(genre, oldSong, newSong) {
|
|
- if (isAdmin() && !isBanned()) {
|
|
|
|
|
|
+ if (isModerator() && !isBanned()) {
|
|
newSong.mid = oldSong.mid;
|
|
newSong.mid = oldSong.mid;
|
|
Playlists.update({type: genre, "songs": oldSong}, {$set: {"songs.$": newSong}});
|
|
Playlists.update({type: genre, "songs": oldSong}, {$set: {"songs.$": newSong}});
|
|
return true;
|
|
return true;
|
|
@@ -733,7 +746,7 @@ Meteor.methods({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
removeSongFromQueue: function(type, mid) {
|
|
removeSongFromQueue: function(type, mid) {
|
|
- if (isAdmin() && !isBanned()) {
|
|
|
|
|
|
+ if (isModerator() && !isBanned()) {
|
|
type = type.toLowerCase();
|
|
type = type.toLowerCase();
|
|
Queues.update({type: type}, {$pull: {songs: {mid: mid}}});
|
|
Queues.update({type: type}, {$pull: {songs: {mid: mid}}});
|
|
} else {
|
|
} else {
|
|
@@ -741,7 +754,7 @@ Meteor.methods({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
removeSongFromPlaylist: function(type, mid) {
|
|
removeSongFromPlaylist: function(type, mid) {
|
|
- if (isAdmin() && !isBanned()) {
|
|
|
|
|
|
+ if (isModerator() && !isBanned()) {
|
|
type = type.toLowerCase();
|
|
type = type.toLowerCase();
|
|
Playlists.update({type: type}, {$pull: {songs: {mid: mid}}});
|
|
Playlists.update({type: type}, {$pull: {songs: {mid: mid}}});
|
|
} else {
|
|
} else {
|
|
@@ -749,7 +762,7 @@ Meteor.methods({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
addSongToPlaylist: function(type, songData) {
|
|
addSongToPlaylist: function(type, songData) {
|
|
- if (isAdmin() && !isBanned()) {
|
|
|
|
|
|
+ if (isModerator() && !isBanned()) {
|
|
type = type.toLowerCase();
|
|
type = type.toLowerCase();
|
|
if (Rooms.find({type: type}).count() === 1) {
|
|
if (Rooms.find({type: type}).count() === 1) {
|
|
if (Playlists.find({type: type}).count() === 0) {
|
|
if (Playlists.find({type: type}).count() === 0) {
|