Chatwoot/app/jobs/contact_avatar_job.rb
Sojan Jose 8daf1fe033
chore: Add down gem for Local file downloads (#2765)
- Add down gem to handle downloading files to host machine
- Remove the LocalResource class
- Introduce max limit for contact avatars send via SDK
2021-08-11 16:40:28 +05:30

13 lines
429 B
Ruby

class ContactAvatarJob < ApplicationJob
queue_as :default
def perform(contact, avatar_url)
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
Rails.logger.info "Exception: invalid avatar url #{avatar_url} : #{e.message}"
end
end