Forráskód Böngészése

Changed song system completely. Might be a bit broken.

KrisVos130 9 éve
szülő
commit
1242fe1d72

+ 5 - 5
app/client/scripts/events.js

@@ -442,7 +442,7 @@ Template.queues.events({
     },
     "click .add-song-button": function(e){
         var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
-        Meteor.call("addSongToPlaylist", genre, this, function(err) {
+        Meteor.call("addSongToPlaylist", this, function(err) {
             console.log(err);
             if (err) {
                 var $toastContent = $('<span><strong>Song not added.</strong> ' + err.reason + '</span>');
@@ -452,7 +452,7 @@ Template.queues.events({
     },
     "click .deny-song-button": function(e){
         var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
-        Meteor.call("removeSongFromQueue", genre, this.mid);
+        Meteor.call("removeSongFromQueue", this.mid);
     },
     "click #play": function() {
         var duration = Session.get("song").duration;
@@ -680,7 +680,7 @@ Template.manageStation.events({
     },
     "click .remove-song-button": function(e){
         var genre = $(e.target).data("genre") || $(e.target).parent().data("genre");
-        Meteor.call("removeSongFromPlaylist", genre, this.mid);
+        Meteor.call("removeSongFromPlaylist", this.mid);
     },
     "click #play": function() {
         var duration = Session.get("song").duration;
@@ -1025,7 +1025,7 @@ Template.room.events({
         var total = YTImportQueue.length;
         YTImportQueue.forEach(function (song) {
             var songData = {type: "YouTube", id: song.id, title: song.title, artist: "", img: ""};
-            Meteor.call("addSongToQueue", Session.get("type"), songData, function (err, res) {
+            Meteor.call("addSongToQueue", songData, function (err, res) {
                 if (err) {
                     console.log(err);
                     failed++;
@@ -1163,7 +1163,7 @@ Template.room.events({
                 $(this).remove();
             });
         } else {
-            Meteor.call("addSongToQueue", genre, songData, function (err, res) {
+            Meteor.call("addSongToQueue", songData, function (err, res) {
                 console.log(err, res);
                 if (err) {
                     $("<div class='alert alert-danger alert-dismissible' role='alert' style='margin-bottom: 0'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'><i class='fa fa-times'></i></span></button><strong>Song not added.</strong> Something went wrong.</div>").prependTo($(".landing")).delay(7000).fadeOut(1000, function () {

+ 11 - 12
app/client/scripts/helpers.js

@@ -196,17 +196,8 @@ Template.profile.helpers({
 });
 
 Template.queues.helpers({
-    queues: function () {
-        var queues = Queues.find({}).fetch();
-        queues.map(function (queue) {
-            if (Rooms.find({type: queue.type}).count() !== 1) {
-                return;
-            } else {
-                queue.display = Rooms.findOne({type: queue.type}).display;
-                return queue;
-            }
-        });
-        return queues;
+    songs: function () {
+        return Queues.find({}).fetch();
     },
     song_image: function() {
         return Session.get("image_url");
@@ -221,7 +212,15 @@ Template.manageStation.helpers({
         var type = id.toLowerCase();
 
         var playlist = Playlists.findOne({type: type});
-        return playlist.songs;
+        var songs = [];
+        if (playlist !== undefined && playlist.songs !== undefined) {
+            playlist.songs.forEach(function(songMid) {
+                console.log(songMid);
+                console.log(Songs.findOne({mid: songMid}));
+                songs.push(Songs.findOne({mid: songMid}));
+            });
+        }
+        return songs;
     },
     song_image: function() {
         return Session.get("image_url");

+ 1 - 0
app/client/scripts/main.js

@@ -18,6 +18,7 @@ Deps.autorun(function() {
     Meteor.subscribe("reports");
     Meteor.subscribe("chat");
     Meteor.subscribe("playlists");
+    Meteor.subscribe("songs");
     Meteor.subscribe("alerts");
     Meteor.subscribe("rooms");
     Meteor.subscribe("userData", Meteor.userId());

+ 38 - 40
app/client/templates/queues.html

@@ -3,49 +3,47 @@
     <div class="landing">
         {{> header}}
         <div class="row">
-            {{#each queues}}
-                <div class="col m8 s8 l8 offset-l2 offset-m1 offset-s2 admin-queue-panel card-panel teal accent-3">
-                    <div class="card-content white-text">
-                        <h3 class="text-center">{{display}} review queue</h3>
-                        <table class="bordered">
-                            <thead>
+            <div class="col m8 s8 l8 offset-l2 offset-m1 offset-s2 admin-queue-panel card-panel teal accent-3">
+                <div class="card-content white-text">
+                    <h3 class="text-center">Review queue</h3>
+                    <table class="bordered">
+                        <thead>
+                        <tr>
+                            <th>Title</th>
+                            <th>Artist(s)</th>
+                            <th>Id</th>
+                            <th>Mid</th>
+                            <th class="table-right-th">Edit</th>
+                            <th class="table-right-th">Add</th>
+                            <th class="table-right-th">Remove</th>
+                        </tr>
+                        </thead>
+                        <tbody>
+                        {{#each songs}}
                             <tr>
-                                <th>Title</th>
-                                <th>Artist(s)</th>
-                                <th>Id</th>
-                                <th>Mid</th>
-                                <th class="table-right-th">Edit</th>
-                                <th class="table-right-th">Add</th>
-                                <th class="table-right-th">Remove</th>
+                                <th align="left" scope="row">{{title}}</th>
+                                <td align="left">{{artist}}</td>
+                                <td align="left">{{id}}</td>
+                                <td align="left">{{mid}}</td>
+                                <td class="table-right-td">
+                                    <button class="btn edit-queue-button" data-genre="{{../type}}"
+                                            data-toggle="modal" data-target="#editModal">Edit
+                                    </button>
+                                </td>
+                                <td class="table-right-td">
+                                    <button class="btn green add-song-button" data-genre="{{../type}}"><i
+                                            class="material-icons">thumb_up</i></button>
+                                </td>
+                                <td class="table-right-td">
+                                    <button class="btn red deny-song-button" data-genre="{{../type}}"><i
+                                            class="material-icons">thumb_down</i></button>
+                                </td>
                             </tr>
-                            </thead>
-                            <tbody>
-                            {{#each songs}}
-                                <tr>
-                                    <th align="left" scope="row">{{title}}</th>
-                                    <td align="left">{{artist}}</td>
-                                    <td align="left">{{id}}</td>
-                                    <td align="left">{{mid}}</td>
-                                    <td class="table-right-td">
-                                        <button class="btn edit-queue-button" data-genre="{{../type}}"
-                                                data-toggle="modal" data-target="#editModal">Edit
-                                        </button>
-                                    </td>
-                                    <td class="table-right-td">
-                                        <button class="btn green add-song-button" data-genre="{{../type}}"><i
-                                                class="material-icons">thumb_up</i></button>
-                                    </td>
-                                    <td class="table-right-td">
-                                        <button class="btn red deny-song-button" data-genre="{{../type}}"><i
-                                                class="material-icons">thumb_down</i></button>
-                                    </td>
-                                </tr>
-                            {{/each}}
-                            </tbody>
-                        </table>
-                    </div>
+                        {{/each}}
+                        </tbody>
+                    </table>
                 </div>
-            {{/each}}
+            </div>
         </div>
     </div>
     <div id="editModal" class="modal modal-fixed-footer">

+ 2 - 1
app/database/collections.js

@@ -5,4 +5,5 @@ Reports = new Mongo.Collection("reports");
 Chat = new Mongo.Collection("chat");
 Alerts = new Mongo.Collection("alerts");
 Deleted = new Mongo.Collection("deleted");
-Feedback = new Mongo.Collection("feedback");
+Feedback = new Mongo.Collection("feedback");
+Songs = new Mongo.Collection("songs");

+ 22 - 21
app/database/schemas.js

@@ -43,6 +43,14 @@ Schemas.FullSong = new SimpleSchema({
         min: 0,
         decimal: true
     },
+    "genres": {
+        type: Array,
+        label: "Array of song genre's"
+    },
+    "genres.$": {
+        type: String,
+        label: "Song genre"
+    },
     "requestedBy": {
         type: String,
         label: "User ID of the person who requested the song"
@@ -96,6 +104,14 @@ Schemas.QueueSong = new SimpleSchema({
         min: 0,
         decimal: true
     },
+    "genres": {
+        type: Array,
+        label: "Array of song genre's"
+    },
+    "genres.$": {
+        type: String,
+        label: "Song genre"
+    },
     "requestedBy": {
         type: String,
         label: "User ID of the person who requested the song"
@@ -237,11 +253,11 @@ Schemas.Playlist = new SimpleSchema({
     },
     songs: {
         type: Array,
-        label: "All songs in that playlist"
+        label: "Array of song MID's"
     },
     "songs.$": {
-        type: Schemas.FullSong,
-        label: "Song object"
+        type: String,
+        label: "Song mid"
     },
     lastSong: {
         type: Number,
@@ -250,22 +266,6 @@ Schemas.Playlist = new SimpleSchema({
     }
 });
 
-Schemas.Queue = new SimpleSchema({
-    type: {
-        type: String,
-        label: "Type of the room the playlist is for",
-        regEx: /^[a-z0-9_]{1,20}$/
-    },
-    songs: {
-        type: Array,
-        label: "All songs in that playlist"
-    },
-    "songs.$": {
-        type: Schemas.QueueSong,
-        label: "Song object"
-    }
-});
-
 Schemas.UserProfile = new SimpleSchema({
     username: {
         type: String,
@@ -503,7 +503,8 @@ Rooms.attachSchema(Schemas.Room);
 Alerts.attachSchema(Schemas.Alert);
 Chat.attachSchema(Schemas.Chat);
 Playlists.attachSchema(Schemas.Playlist);
-Queues.attachSchema(Schemas.Queue);
+Queues.attachSchema(Schemas.QueueSong);
 Meteor.users.attachSchema(Schemas.User);
 Reports.attachSchema(Schemas.Report);
-Feedback.attachSchema(Schemas.Feedback);
+Feedback.attachSchema(Schemas.Feedback);
+Songs.attachSchema(Schemas.FullSong);

+ 93 - 136
app/server/server.js

@@ -21,6 +21,10 @@ Meteor.startup(function () {
     Accounts.config({
         sendVerificationEmail: true
     });
+
+    if (Songs.find().count() === 0) {
+        Songs.insert(default_song);
+    }
 });
 
 var default_song = {
@@ -35,7 +39,8 @@ var default_song = {
     duration: 181,
     skipDuration: 0,
     requestedBy: "NONE",
-    approvedBy: "NONE"
+    approvedBy: "NONE",
+    genres: []
 };
 
 Alerts.update({active: true}, {$set: {active: false}}, {multi: true});
@@ -136,9 +141,18 @@ function createRoom(display, tag, private) {
 
 function Station(type) {
     if (Playlists.find({type: type}).count() === 0) {
-        Playlists.insert({type: type, songs: [default_song], lastSong: 0});
-    } else if (Playlists.findOne({type: type}).songs.length === 0) {
-        Playlists.update({type: type}, {$push: {songs: default_song}});
+        Playlists.insert({type: type, songs: [default_song.mid], lastSong: 0});
+    }
+    if (Songs.find({genres: type}).count() > 0) {
+        var list = Songs.find({genres: type}).fetch();
+        list.forEach(function(song){
+            if (Playlists.findOne({type: type, songs: song.mid}) === undefined) {
+                Playlists.update({type: type}, {$push: {songs: song.mid}});
+            }
+        });
+    }
+    if (Playlists.findOne({type: type}).songs.length === 0) {
+        Playlists.update({type: type}, {$push: {songs: default_song.mid}});
     }
     Meteor.publish(type, function () {
         return undefined;
@@ -152,11 +166,11 @@ function Station(type) {
     if (currentSong < (songs.length - 1)) {
         currentSong++;
     } else currentSong = 0;
-    var currentTitle = songs[currentSong].title;
+    var currentMid = songs[currentSong];
 
     var res = Rooms.update({type: type}, {
         $set: {
-            currentSong: {song: songs[currentSong], started: startedAt},
+            currentSong: {song: Songs.findOne({mid: songs[currentSong]}), started: startedAt},
             users: 0
         }
     });
@@ -167,8 +181,8 @@ function Station(type) {
         voteNum = 0;
         Rooms.update({type: type}, {$set: {votes: 0}});
         songs = Playlists.findOne({type: type}).songs;
-        songs.forEach(function (song, index) {
-            if (song.title === currentTitle) {
+        songs.forEach(function (mid, index) {
+            if (mid === currentMid) {
                 currentSong = index;
             }
         });
@@ -179,17 +193,11 @@ function Station(type) {
         if (currentSong === 0) {
             this.shufflePlaylist();
         } else {
-            if (songs[currentSong].mid === undefined) {
-                var newSong = songs[currentSong];
-                newSong.mid = createUniqueSongId();
-                songs[currentSong].mid = newSong.mid;
-                Playlists.update({type: type, "songs": songs[currentSong]}, {$set: {"songs.$": newSong}});
-            }
-            currentTitle = songs[currentSong].title;
+            currentMid = songs[currentSong];
             Playlists.update({type: type}, {$set: {lastSong: currentSong}});
             Rooms.update({type: type}, {$set: {timePaused: 0}});
             this.songTimer();
-            Rooms.update({type: type}, {$set: {currentSong: {song: songs[currentSong], started: startedAt}}});
+            Rooms.update({type: type}, {$set: {currentSong: {song: Songs.findOne({mid: songs[currentSong]}), started: startedAt}}});
         }
     };
 
@@ -202,16 +210,13 @@ function Station(type) {
         Playlists.update({type: type}, {$set: {"songs": []}});
         songs = shuffle(songs);
         songs.forEach(function (song) {
-            if (song.mid === undefined) {
-                song.mid = createUniqueSongId();
-            }
             Playlists.update({type: type}, {$push: {"songs": song}});
         });
-        currentTitle = songs[currentSong].title;
+        currentMid = songs[currentSong];
         Playlists.update({type: type}, {$set: {lastSong: currentSong}});
         Rooms.update({type: type}, {$set: {timePaused: 0}});
         this.songTimer();
-        Rooms.update({type: type}, {$set: {currentSong: {song: songs[currentSong], started: startedAt}}});
+        Rooms.update({type: type}, {$set: {currentSong: {song: Songs.findOne({mid: songs[currentSong]}), started: startedAt}}});
     };
 
     Rooms.update({type: type}, {$set: {timePaused: 0}});
@@ -226,7 +231,7 @@ function Station(type) {
         }
         timer = new Timer(function () {
             self.skipSong();
-        }, songs[currentSong].duration * 1000);
+        }, Songs.findOne({mid: songs[currentSong]}).duration * 1000);
     };
 
     var state = Rooms.findOne({type: type}).state;
@@ -452,6 +457,10 @@ Meteor.publish("rooms", function () {
     return Rooms.find({});
 });
 
+Meteor.publish("songs", function () {
+    return Songs.find({});
+});
+
 Meteor.publish("queues", function () {
     return Queues.find({});
 });
@@ -926,66 +935,50 @@ Meteor.methods({
             return true;
         }
     },
-    addSongToQueue: function (type, songData) {
+    addSongToQueue: function (songData) {
         if (Meteor.userId() && !isBanned()) {
-            type = type.toLowerCase();
             var userId = Meteor.userId();
-            if (Rooms.find({type: type}).count() === 1) {
-                if (Queues.find({type: type}).count() === 0) {
-                    Queues.insert({type: type, songs: []});
+            var requiredProperties = ["title", "artist", "img", "id", "genres"];
+            if (songData !== undefined && Object.keys(songData).length === requiredProperties.length) {
+                for (var property in requiredProperties) {
+                    if (songData[requiredProperties[property]] === undefined) {
+                        throw new Meteor.Error(403, "Invalid data.");
+                    }
                 }
-                var requiredProperties = ["title", "artist", "img", "id"];
-                if (songData !== undefined && Object.keys(songData).length === requiredProperties.length) {
-                    for (var property in requiredProperties) {
-                        if (songData[requiredProperties[property]] === undefined) {
-                            throw new Meteor.Error(403, "Invalid data.");
+                songData.duration = Number(getSongDuration(songData.title, songData.artist));
+                songData.img = getSongAlbumArt(songData.title, songData.artist) || "";
+                songData.skipDuration = 0;
+                songData.likes = 0;
+                songData.dislikes = 0;
+                songData.requestedBy = userId;
+                var mid = createUniqueSongId();
+                if (mid !== undefined) {
+                    songData.mid = mid;
+                    Queues.insert(songData, function(err, res) {
+                        if (err) {
+                            console.log(err);
+                            throw err.sanitizedError;
+                        } else {
+                            var songsRequested = (Meteor.user().profile !== undefined && Meteor.user().profile.statistics !== undefined && Meteor.user().profile.statistics.songsRequested !== undefined) ? Meteor.user().profile.statistics.songsRequested : 0;
+                            songsRequested++;
+                            Meteor.users.update(Meteor.userId(), {$set: {"profile.statistics.songsRequested": songsRequested}}); // TODO Make mongo query use $inc correctly.
+                            return true;
                         }
-                    }
-                    songData.duration = Number(getSongDuration(songData.title, songData.artist));
-                    songData.img = getSongAlbumArt(songData.title, songData.artist) || "";
-                    songData.skipDuration = 0;
-                    songData.likes = 0;
-                    songData.dislikes = 0;
-                    var mid = createUniqueSongId();
-                    if (mid !== undefined) {
-                        songData.mid = mid;
-                        Queues.update({type: type}, {
-                            $push: {
-                                songs: {
-                                    id: songData.id,
-                                    mid: songData.mid,
-                                    title: songData.title,
-                                    artist: songData.artist,
-                                    duration: songData.duration,
-                                    skipDuration: songData.skipDuration,
-                                    likes: songData.likes,
-                                    dislikes: songData.dislikes,
-                                    img: songData.img,
-                                    requestedBy: userId
-                                }
-                            }
-                        });
-                        var songsRequested = (Meteor.user().profile !== undefined && Meteor.user().profile.statistics !== undefined && Meteor.user().profile.statistics.songsRequested !== undefined) ? Meteor.user().profile.statistics.songsRequested : 0;
-                        songsRequested++;
-                        Meteor.users.update(Meteor.userId(), {$set: {"profile.statistics.songsRequested": songsRequested}}); // TODO Make mongo query use $inc correctly.
-                        return true;
-                    } else {
-                        throw new Meteor.Error(500, "Am error occured.");
-                    }
+                    });
                 } else {
-                    throw new Meteor.Error(403, "Invalid data.");
+                    throw new Meteor.Error(500, "Am error occured.");
                 }
             } else {
-                throw new Meteor.Error(403, "Invalid genre.");
+                throw new Meteor.Error(403, "Invalid data.");
             }
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");
         }
     },
-    updateQueueSong: function (genre, oldSong, newSong) {
+    updateQueueSong: function (mid, newSong) {
         if (isModerator() && !isBanned()) {
-            newSong.mid = oldSong.mid;
-            Queues.update({type: genre, "songs": oldSong}, {$set: {"songs.$": newSong}}, function(err) {
+            newSong.mid = mid;
+            Queues.update({mid: mid}, newSong, function(err) {
                 console.log(err);
                 if (err) {
                     throw err.sanitizedError;
@@ -997,13 +990,11 @@ Meteor.methods({
             throw new Meteor.Error(403, "Invalid permissions.");
         }
     },
-    updatePlaylistSong: function (genre, oldSong, newSong) {
+    updatePlaylistSong: function (mid, newSong) {
         if (isModerator() && !isBanned()) {
-            newSong.mid = oldSong.mid;
+            newSong.mid = mid;
             newSong.approvedBy = Meteor.userId();
-            console.log(genre);
-            console.log(oldSong);
-            Playlists.update({type: genre, "songs": oldSong}, {$set: {"songs.$": newSong}}, function(err) {
+            Playlists.update({mid: mid}, newSong, function(err) {
                 console.log(err);
                 if (err) {
                     throw err.sanitizedError;
@@ -1016,84 +1007,52 @@ Meteor.methods({
             throw new Meteor.Error(403, "Invalid permissions.");
         }
     },
-    removeSongFromQueue: function (type, mid) {
+    removeSongFromQueue: function (mid) {
         if (isModerator() && !isBanned()) {
-            type = type.toLowerCase();
-            Queues.update({type: type}, {$pull: {songs: {mid: mid}}});
+            Queues.remove({mid: mid});
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");
         }
     },
-    removeSongFromPlaylist: function (type, mid) {
+    removeSongFromPlaylist: function (mid) {
         if (isModerator() && !isBanned()) {
-            type = type.toLowerCase();
-            var songs = Playlists.findOne({type: type}).songs;
-            var song = undefined;
-            songs.forEach(function (curr_song) {
-                if (mid === curr_song.mid) {
-                    song = curr_song;
-                    return;
-                }
-            });
-            Playlists.update({type: type}, {$pull: {songs: {mid: mid}}});
+            Playlists.remove({}, {$pull: {songs: mid}});
+            var song = Songs.findOne({mid: mid});
+            Songs.remove({mid: mid});
             if (song !== undefined) {
                 song.deletedBy = Meteor.userId();
                 song.deletedAt = new Date(Date.now());
-                if (Deleted.find({type: type}).count() === 0) {
-                    Deleted.insert({type: type, songs: [song]});
-                } else {
-                    Deleted.update({type: type}, {$push: {songs: song}});
-                }
+                song.deletedType = "song";
+                Deleted.insert(song);
             }
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");
         }
     },
-    addSongToPlaylist: function (type, songData) {
-        console.log(songData);
+    addSongToPlaylist: function (songData) {
         if (isModerator() && !isBanned()) {
-            type = type.toLowerCase();
-            if (Rooms.find({type: type}).count() === 1) {
-                if (Playlists.find({type: type}).count() === 0) {
-                    Playlists.insert({type: type, songs: []});
-                }
-                var requiredProperties = ["mid", "id", "title", "artist", "duration", "skipDuration", "img", "likes", "dislikes", "requestedBy"];
-                if (songData !== undefined && Object.keys(songData).length === requiredProperties.length) {
-                    for (var property in requiredProperties) {
-                        if (songData[requiredProperties[property]] === undefined) {
-                            throw new Meteor.Error(403, "Invalid data.");
-                        }
+            var requiredProperties = ["_id", "mid", "id", "title", "artist", "duration", "skipDuration", "img", "likes", "dislikes", "requestedBy", "genres"];
+            if (songData !== undefined && Object.keys(songData).length === requiredProperties.length) {
+                for (var property in requiredProperties) {
+                    if (songData[requiredProperties[property]] === undefined) {
+                        throw new Meteor.Error(403, "Invalid data.");
                     }
-                    Playlists.update({type: type}, {
-                        $push: {
-                            songs: {
-                                id: songData.id,
-                                mid: songData.mid,
-                                title: songData.title,
-                                artist: songData.artist,
-                                duration: songData.duration,
-                                skipDuration: Number(songData.skipDuration),
-                                img: songData.img,
-                                type: songData.type,
-                                likes: Number(songData.likes),
-                                dislikes: Number(songData.dislikes),
-                                requestedBy: songData.requestedBy,
-                                approvedBy: Meteor.userId()
-                            }
-                        }
-                    });
-                    Queues.update({type: type}, {$pull: {songs: {mid: songData.mid}}});
-                    getStation(type, function (station) {
-                        if (station === undefined) {
-                            stations.push(new Station(type));
-                        }
-                    });
-                    return true;
-                } else {
-                    throw new Meteor.Error(403, "Invalid data.");
                 }
+                delete songData._id;
+                songData.approvedBy = Meteor.userId();
+                Songs.insert(songData);
+                Queues.remove({mid: songData.mid});
+                songData.genres.forEach(function(genre) {
+                    genre = genre.toLowerCase();
+                    if (Playlists.findOne({type: genre}) === undefined) {
+                        Playlists.insert({type: genre, songs: [songData.mid]});
+                    } else {
+                        Playlists.update({type: genre}, {$push: {songs: songData.mid}});
+                    }
+                });
+                return true;
             } else {
-                throw new Meteor.Error(403, "Invalid genre.");
+                throw new Meteor.Error(403, "Invalid data.");
             }
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");
@@ -1109,8 +1068,6 @@ Meteor.methods({
     deleteRoom: function (type) {
         if (isAdmin() && !isBanned()) {
             Rooms.remove({type: type});
-            Playlists.remove({type: type});
-            Queues.remove({type: type});
             return true;
         } else {
             throw new Meteor.Error(403, "Invalid permissions.");