* Dropped all references to Resque * Moved all jobs under app/workers since that's the Sidekiq convention * Renamed Jobs module to Worker to match new location * Adapted all jobs to Sidekiq * Replaced all enqueue calls with perform_async * Dropped Resque hacks from specs and features, replaced with sidekig/testing in RSpec and sidekig/testing/inline in Cucumber * Updated scripts to start a Sidekiq server * Inline Sidekiq sinatra app * Let Sidekiq create the actual Redis instance * Workaround already initialized constant warnings in service models * Resolved ToDo in one job definition by creating proper exception clases for some errors in receiving posts * Added sidekiq section to configuration to make it completly configurable to the user * Add Sidekiq middleware for clean backtraces * Delay HttpMulti retry to give offline pods a chance to come back up * Do not retry on GUID already taken and alike errors * Be graceful about deleted posts in GatherOEmbedData
29 lines
896 B
Ruby
29 lines
896 B
Ruby
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
|
# licensed under the Affero General Public License version 3 or later. See
|
|
# the COPYRIGHT file.
|
|
|
|
|
|
module Workers
|
|
class FetchProfilePhoto < Base
|
|
sidekiq_options queue: :photos
|
|
|
|
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
|
|
end
|
|
end
|