2020-04-03 07:34:58 +00:00
|
|
|
class ContactAvatarJob < ApplicationJob
|
|
|
|
queue_as :default
|
|
|
|
|
|
|
|
def perform(contact, avatar_url)
|
|
|
|
avatar_resource = LocalResource.new(avatar_url)
|
|
|
|
contact.avatar.attach(io: avatar_resource.file, filename: avatar_resource.tmp_filename, content_type: avatar_resource.encoding)
|
2020-09-10 13:49:15 +00:00
|
|
|
rescue Errno::ETIMEDOUT, Errno::ECONNREFUSED, SocketError, NoMethodError => e
|
2020-09-18 13:20:53 +00:00
|
|
|
Rails.logger.info "Exception: invalid avatar url #{avatar_url} : #{e.message}"
|
2020-04-03 07:34:58 +00:00
|
|
|
end
|
|
|
|
end
|