Files
leadchat/app/jobs/avatar/avatar_from_url_job.rb
Sojan Jose 85e57c2e94 chore: Reorganize Sidekiq Queues (#6976)
- Rearrange and reprioritize current sidekiq queues
- Trim the unnecessary queues

ref: https://linear.app/chatwoot/issue/CW-1480/chore-run-all-sidekiq-jobs-async
2023-05-04 15:44:16 +05:30

16 lines
507 B
Ruby

class Avatar::AvatarFromUrlJob < ApplicationJob
queue_as :low
def perform(avatarable, avatar_url)
return unless avatarable.respond_to?(:avatar)
avatar_file = Down.download(
avatar_url,
max_size: 15 * 1024 * 1024
)
avatarable.avatar.attach(io: avatar_file, filename: avatar_file.original_filename, content_type: avatar_file.content_type)
rescue Down::NotFound, Down::Error => e
Rails.logger.error "Exception: invalid avatar url #{avatar_url} : #{e.message}"
end
end