Skip to content
Snippets Groups Projects
Commit 75a51d13 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Send message with uploaded file after upload ends

parent c8c9cf7d
No related branches found
No related tags found
No related merge requests found
...@@ -467,16 +467,10 @@ Template.room.events ...@@ -467,16 +467,10 @@ Template.room.events
FS?.Utility?.eachFile e, (file) -> FS?.Utility?.eachFile e, (file) ->
newFile = new (FS.File)(file) newFile = new (FS.File)(file)
newFile.rid = Session.get('openedRoom') newFile.rid = Session.get('openedRoom')
newFile.userId = Meteor.userId()
Files.insert newFile, (error, fileObj) -> Files.insert newFile, (error, fileObj) ->
unless error unless error
toastr.success 'Upload succeeded!' toastr.success 'Upload succeeded!'
console.log('room fileObj', fileObj) if window.rocketDebug
Meteor.call 'sendMessage',
_id: Random.id()
rid: fileObj.rid
msg: 'File Uploaded: *' + fileObj.original.name + '* \n' + document.location.origin + '/cfs/files/Files/' + fileObj._id
file:
_id: fileObj._id
Template.room.onCreated -> Template.room.onCreated ->
# this.scrollOnBottom = true # this.scrollOnBottom = true
......
if FS? if FS?
@fileStore = new FS.Store.GridFS 'files' @fileStore = new FS.Store.GridFS 'files'
fileStore.on 'stored', Meteor.bindEnvironment (storeName, fileObj) ->
Meteor.runAsUser fileObj.userId, ->
Meteor.call 'sendMessage',
_id: Random.id()
rid: fileObj.rid
msg: """
File Uploaded: *#{fileObj.original.name}*
#{Meteor.absoluteUrl()}/cfs/files/Files/#{fileObj._id}
"""
file:
_id: fileObj._id
@Files = new FS.Collection 'Files', @Files = new FS.Collection 'Files',
stores: [fileStore], stores: [fileStore],
filter: filter:
maxSize: 1048576, maxSize: 2097152,
allow: allow:
contentTypes: ['image/*'] contentTypes: ['image/*']
onInvalid: (message) -> onInvalid: (message) ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment