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

Allow upsert messages with _id and use upsert in file upload

parent eb9256c1
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ if FS? ...@@ -14,6 +14,7 @@ if FS?
""" """
file: file:
_id: fileObj._id _id: fileObj._id
, {upsert: true}
@Files = new FS.Collection 'Files', @Files = new FS.Collection 'Files',
stores: [fileStore], stores: [fileStore],
......
RocketChat.sendMessage = (user, message, room) -> RocketChat.sendMessage = (user, message, room, options) ->
if not user or not message or not room._id if not user or not message or not room._id
return false return false
...@@ -15,7 +15,10 @@ RocketChat.sendMessage = (user, message, room) -> ...@@ -15,7 +15,10 @@ RocketChat.sendMessage = (user, message, room) ->
message = RocketChat.callbacks.run 'beforeSaveMessage', message message = RocketChat.callbacks.run 'beforeSaveMessage', message
message._id = ChatMessage.insert message if message._id? and options?.upsert is true
ChatMessage.upsert {_id: message._id}, message
else
message._id = ChatMessage.insert message
### ###
Defer other updates as their return is not interesting to the user Defer other updates as their return is not interesting to the user
......
Meteor.methods Meteor.methods
sendMessage: (message) -> sendMessage: (message, options) ->
if message.msg?.length > RocketChat.settings.get('Message_MaxAllowedSize') if message.msg?.length > RocketChat.settings.get('Message_MaxAllowedSize')
throw new Meteor.Error 400, '[methods] sendMessage -> Message size exceed Message_MaxAllowedSize' throw new Meteor.Error 400, '[methods] sendMessage -> Message size exceed Message_MaxAllowedSize'
...@@ -15,4 +15,4 @@ Meteor.methods ...@@ -15,4 +15,4 @@ Meteor.methods
if not room if not room
return false return false
RocketChat.sendMessage user, message, room RocketChat.sendMessage user, message, room, options
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