mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-03-22 04:45:46 -04:00
FEATURE: background job to make sure emoticons aren't too big
This commit is contained in:
parent
9a4e5c04d9
commit
2507f99135
2 changed files with 16 additions and 0 deletions
app
14
app/jobs/regular/resize_emoji.rb
Normal file
14
app/jobs/regular/resize_emoji.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
module Jobs
|
||||
|
||||
class ResizeEmoji < Jobs::Base
|
||||
|
||||
def execute(args)
|
||||
path = args[:path]
|
||||
return unless File.exists?(path)
|
||||
|
||||
# make sure emoji aren't too big
|
||||
OptimizedImage.resize(path, path, 60, 60, true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -56,6 +56,8 @@ class Emoji
|
|||
File.open(path, "wb") { |f| f << file.tempfile.read }
|
||||
# clear the cache
|
||||
Emoji.clear_cache
|
||||
# launch resize job
|
||||
Jobs.enqueue(:resize_emoji, path: path)
|
||||
# return created emoji
|
||||
Emoji.custom.detect { |e| e.name == name }
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue