Just enqueue a job on service create for now, since our queues are empty. Resque status will let us run the job and show the user a spinny without locking up a thin
This commit is contained in:
parent
3e8f455cbc
commit
55c5b4e525
3 changed files with 9 additions and 4 deletions
|
|
@ -13,14 +13,14 @@ class UsersController < ApplicationController
|
|||
def edit
|
||||
@aspect = :user_edit
|
||||
@user = current_user
|
||||
@email_prefs = Hash.new(true)
|
||||
@email_prefs = Hash.new(true)
|
||||
@user.user_preferences.each do |pref|
|
||||
@email_prefs[pref.email_type] = false
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
|
||||
u = params[:user]
|
||||
@user = current_user
|
||||
|
||||
|
|
@ -102,6 +102,7 @@ class UsersController < ApplicationController
|
|||
if @step == 3
|
||||
@requests = Request.where(:recipient_id => @person.id).includes(:sender => :profile).all
|
||||
@friends = service ? service.finder(:local => true) : {}
|
||||
@friends ||= {}
|
||||
@friends.delete_if{|key, value| @requests.any?{ |r| r.sender_id == value[:person].id} }
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class Service < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
has_many :service_users
|
||||
after_create do
|
||||
Resque.enqueue(Job::UpdateServiceUsers, self.id) if s.respond_to? :save_friends
|
||||
Resque.enqueue(Job::UpdateServiceUsers, self.id) if self.respond_to? :save_friends
|
||||
end
|
||||
|
||||
def public_message(post, length, url = "")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
class Services::Facebook < Service
|
||||
MAX_CHARACTERS = 420
|
||||
|
||||
after_create do
|
||||
Resque.enqueue(Job::UpdateServiceUsers, self.id)
|
||||
end
|
||||
|
||||
def provider
|
||||
"facebook"
|
||||
end
|
||||
|
|
@ -38,7 +42,7 @@ class Services::Facebook < Service
|
|||
end
|
||||
|
||||
def save_friends
|
||||
url = "https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=#{URI.escape(self.access_token)}"
|
||||
url = "https://graph.facebook.com/me/friends?fields[]=name&fields[]=picture&access_token=#{URI.escape(self.access_token)}"
|
||||
response = RestClient.get(url)
|
||||
data = JSON.parse(response.body)['data']
|
||||
data.each{ |p|
|
||||
|
|
|
|||
Loading…
Reference in a new issue