FEATURE: background job to make sure emoticons aren't too big

This commit is contained in:
Régis Hanol 2015-01-29 18:36:35 +01:00
parent 9a4e5c04d9
commit 2507f99135
2 changed files with 16 additions and 0 deletions
app
jobs/regular
models

View 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

View file

@ -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