make sure we pass in the user_id when creating avatar thumbnails
This commit is contained in:
parent
fe4f8b1519
commit
0483f05154
|
@ -17,5 +17,9 @@ export default Em.Component.extend(UploadMixin, {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.sendAction("done");
|
this.sendAction("done");
|
||||||
}
|
},
|
||||||
|
|
||||||
|
data: function() {
|
||||||
|
return { user_id: this.get("user_id") };
|
||||||
|
}.property("user_id")
|
||||||
});
|
});
|
||||||
|
|
|
@ -21,6 +21,7 @@ export default RestrictedUserRoute.extend(ShowFooter, {
|
||||||
// all the properties needed for displaying the avatar selector modal
|
// all the properties needed for displaying the avatar selector modal
|
||||||
const controller = this.controllerFor('avatar-selector'),
|
const controller = this.controllerFor('avatar-selector'),
|
||||||
props = this.modelFor('user').getProperties(
|
props = this.modelFor('user').getProperties(
|
||||||
|
'id',
|
||||||
'email',
|
'email',
|
||||||
'username',
|
'username',
|
||||||
'uploaded_avatar_id',
|
'uploaded_avatar_id',
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</label>
|
</label>
|
||||||
{{avatar-uploader username=username
|
{{avatar-uploader username=username
|
||||||
|
user_id=id
|
||||||
uploadedAvatarTemplate=uploadedAvatarTemplate
|
uploadedAvatarTemplate=uploadedAvatarTemplate
|
||||||
custom_avatar_upload_id=custom_avatar_upload_id
|
custom_avatar_upload_id=custom_avatar_upload_id
|
||||||
uploading=uploading
|
uploading=uploading
|
||||||
|
|
|
@ -34,7 +34,7 @@ class UploadsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if upload.errors.empty? && FileHelper.is_image?(filename)
|
if upload.errors.empty? && FileHelper.is_image?(filename)
|
||||||
Jobs.enqueue(:create_thumbnails, upload_id: upload.id, type: type)
|
Jobs.enqueue(:create_thumbnails, upload_id: upload.id, type: type, user_id: params[:user_id])
|
||||||
end
|
end
|
||||||
|
|
||||||
data = upload.errors.empty? ? upload : { errors: upload.errors.values.flatten }
|
data = upload.errors.empty? ? upload : { errors: upload.errors.values.flatten }
|
||||||
|
|
|
@ -3,21 +3,24 @@ module Jobs
|
||||||
class CreateThumbnails < Jobs::Base
|
class CreateThumbnails < Jobs::Base
|
||||||
|
|
||||||
def execute(args)
|
def execute(args)
|
||||||
upload_id = args[:upload_id]
|
|
||||||
type = args[:type]
|
type = args[:type]
|
||||||
|
upload_id = args[:upload_id]
|
||||||
|
|
||||||
raise Discourse::InvalidParameters.new(:upload_id) if upload_id.blank?
|
|
||||||
raise Discourse::InvalidParameters.new(:type) if type.blank?
|
raise Discourse::InvalidParameters.new(:type) if type.blank?
|
||||||
|
raise Discourse::InvalidParameters.new(:upload_id) if upload_id.blank?
|
||||||
|
|
||||||
# only need to generate thumbnails for avatars
|
# only need to generate thumbnails for avatars
|
||||||
return if type != "avatar"
|
return if type != "avatar"
|
||||||
|
|
||||||
upload = Upload.find(upload_id)
|
upload = Upload.find(upload_id)
|
||||||
|
|
||||||
self.send("create_thumbnails_for_#{type}", upload)
|
user_id = args[:user_id] || upload.user_id
|
||||||
|
user = User.find(user_id)
|
||||||
|
|
||||||
|
self.send("create_thumbnails_for_#{type}", upload, user)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_thumbnails_for_avatar(upload)
|
def create_thumbnails_for_avatar(upload, user)
|
||||||
Discourse.avatar_sizes.each do |size|
|
Discourse.avatar_sizes.each do |size|
|
||||||
OptimizedImage.create_for(upload, size, size, allow_animation: SiteSetting.allow_animated_avatars)
|
OptimizedImage.create_for(upload, size, size, allow_animation: SiteSetting.allow_animated_avatars)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue