2020-04-03 07:34:58 +00:00
|
|
|
class ContactAvatarJob < ApplicationJob
|
|
|
|
queue_as :default
|
|
|
|
|
|
|
|
def perform(contact, avatar_url)
|
2021-08-11 11:10:28 +00:00
|
|
|
avatar_file = Down.download(
|
|
|
|
avatar_url,
|
|
|
|
max_size: 15 * 1024 * 1024
|
|
|
|
)
|
|
|
|
contact.avatar.attach(io: avatar_file, filename: avatar_file.original_filename, content_type: avatar_file.content_type)
|
|
|
|
rescue Down::Error => e
|
2022-03-28 12:44:30 +00:00
|
|
|
Rails.logger.error "Exception: invalid avatar url #{avatar_url} : #{e.message}"
|
2020-04-03 07:34:58 +00:00
|
|
|
end
|
|
|
|
end
|