summaryrefslogtreecommitdiffstats
path: root/app/core/files.js
diff options
context:
space:
mode:
authorHoussam Haidar <houssam@sdelements.com>2015-02-04 01:28:05 -0500
committerHoussam Haidar <houssam@sdelements.com>2015-02-04 01:28:05 -0500
commit946a9d5234fe085e9f87805e6eb63224cf8c935c (patch)
tree9ffdbdeec893f0d113ce2148432bc180850e7dc2 /app/core/files.js
parent6578e1aa912a029bce41967b66b562670865a5fb (diff)
downloadlets-chat-946a9d5234fe085e9f87805e6eb63224cf8c935c.zip
lets-chat-946a9d5234fe085e9f87805e6eb63224cf8c935c.tar.gz
lets-chat-946a9d5234fe085e9f87805e6eb63224cf8c935c.tar.bz2
Switch to dropzone and make uploads actually work
Diffstat (limited to 'app/core/files.js')
-rw-r--r--app/core/files.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/core/files.js b/app/core/files.js
index 1c4dd75..90584ef 100644
--- a/app/core/files.js
+++ b/app/core/files.js
@@ -31,10 +31,14 @@ FileManager.prototype.create = function(options, cb) {
}
Room.findById(options.room, function(err, room) {
+
if (err) {
console.error(err);
return cb(err);
}
+ if (!room) {
+ return cb('No room found!');
+ }
if (room.archived) {
return cb('Room is archived.');
}
@@ -59,7 +63,11 @@ FileManager.prototype.create = function(options, cb) {
}
cb(null, savedFile, room, user);
this.core.emit('files:new', savedFile, room, user);
-
+ options.post && this.core.messages.create({
+ room: room,
+ owner: user,
+ text: 'file:' + savedFile._id
+ });
}.bind(this));
}.bind(this));
}.bind(this));