Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added room Id field for better relationship between objects. #965

Merged
merged 1 commit into from
Oct 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/lib/fileUpload.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ readAsArrayBuffer = (file, callback) ->
name: file.name or file.file.name
size: file.file.size
type: file.file.type
rid: roomId

upload = new UploadFS.Uploader
store: Meteor.fileStore
Expand Down
27 changes: 27 additions & 0 deletions server/startup/migrations/v20.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Meteor.startup ->
Migrations.add
version: 20
up: ->
###
# Migrate existing `rocketchat_uploads` documents to include the room Id
# where the file was uploaded to. The room Id is retrieved from the message
# document created after the file upload.
###

# list of channel messages which were created after uploading a file
msgQuery =
rid: { $exists: true }
'file._id': { $exists: true }
msgOptions =
fields:
_id: 1
rid: 1
'file._id': 1
cursorFileMessages = RocketChat.models.Messages.find(msgQuery, msgOptions);
return unless cursorFileMessages.count()

_.each( cursorFileMessages.fetch(), (msg) ->
fileCollection.update({ _id: msg?.file?._id }, { $set: { rid: msg.rid } }, { $multi: true })
)

console.log 'Updated rocketchat_uploads documents to include the room Id in which they were sent.'