FIX: when uploading same file was pasted into multiple composers

This commit is contained in:
Sam 2015-05-28 15:08:54 +10:00
parent f3a5a6f8dc
commit bb3fb37650
4 changed files with 5 additions and 4 deletions

View File

@ -153,7 +153,7 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
memory_profiler (0.9.0)
message_bus (1.0.11)
message_bus (1.0.12)
rack (>= 1.1.3)
redis
metaclass (0.0.4)

View File

@ -22,7 +22,7 @@ export default Em.Mixin.create({
});
$upload.fileupload({
url: uploadUrl + ".json?authenticity_token=" + encodeURIComponent(csrf),
url: uploadUrl + ".json?client_id=" + this.messageBus.clientId + "&authenticity_token=" + encodeURIComponent(csrf),
dataType: "json",
dropZone: $upload,
pasteZone: $upload

View File

@ -332,7 +332,7 @@ const ComposerView = Discourse.View.extend(Ember.Evented, {
});
$uploadTarget.fileupload({
url: Discourse.getURL("/uploads.json?authenticity_token=" + encodeURIComponent(csrf)),
url: Discourse.getURL("/uploads.json?client_id=" + this.messageBus.clientId + "&authenticity_token=" + encodeURIComponent(csrf)),
dataType: "json",
pasteZone: $uploadTarget,
});

View File

@ -6,6 +6,7 @@ class UploadsController < ApplicationController
type = params.require(:type)
file = params[:file] || params[:files].first
url = params[:url]
client_id = params[:client_id]
Scheduler::Defer.later("Create Upload") do
begin
@ -38,7 +39,7 @@ class UploadsController < ApplicationController
data = upload.errors.empty? ? upload : { errors: upload.errors.values.flatten }
MessageBus.publish("/uploads/#{type}", data.as_json, user_ids: [current_user.id])
MessageBus.publish("/uploads/#{type}", data.as_json, client_ids: [client_id])
ensure
tempfile.try(:close!) rescue nil
end