Class: Workers::FetchProfilePhoto

Inherits:
Base
  • Object
show all
Defined in:
app/workers/fetch_profile_photo.rb

Instance Method Summary collapse

Methods inherited from Base

#suppress_annoying_errors

Instance Method Details

#perform(user_id, service_id, fallback_image_url = nil) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/workers/fetch_profile_photo.rb', line 10

def perform(user_id, service_id, fallback_image_url = nil)
  service = Service.find(service_id)

  image_url = service.profile_photo_url
  image_url ||= fallback_image_url

  return unless image_url

  user = User.find(user_id)

  @photo = Photo.diaspora_initialize(:author => user.person, :image_url => image_url, :pending => true)
  @photo.save!
  
  profile_params = {:image_url => @photo.url(:thumb_large),
                   :image_url_medium => @photo.url(:thumb_medium),
                   :image_url_small => @photo.url(:thumb_small)}
  user.update_profile(profile_params)
end