summaryrefslogtreecommitdiffstats
path: root/app/core/files.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/core/files.js')
-rw-r--r--app/core/files.js33
1 files changed, 29 insertions, 4 deletions
diff --git a/app/core/files.js b/app/core/files.js
index a51d859..7b5efa8 100644
--- a/app/core/files.js
+++ b/app/core/files.js
@@ -98,6 +98,8 @@ FileManager.prototype.create = function(options, cb) {
};
FileManager.prototype.list = function(options, cb) {
+ var Room = mongoose.model('Room');
+
if (!enabled) {
return cb(null, []);
}
@@ -148,14 +150,37 @@ FileManager.prototype.list = function(options, cb) {
find.sort({ 'uploaded': 1 });
}
- find
- .limit(options.take)
- .exec(function(err, files) {
+ Room.findById(options.room, function(err, room) {
if (err) {
console.error(err);
return cb(err);
}
- cb(null, files);
+
+ var opts = {
+ userId: options.userId,
+ password: options.password
+ };
+
+ room.canJoin(opts, function(err, canJoin) {
+ if (err) {
+ console.error(err);
+ return cb(err);
+ }
+
+ if (!canJoin) {
+ return cb(null, []);
+ }
+
+ find
+ .limit(options.take)
+ .exec(function(err, files) {
+ if (err) {
+ console.error(err);
+ return cb(err);
+ }
+ cb(null, files);
+ });
+ });
});
};