Skip to content
Browse files

Fixing facebook friends request errors

  • Loading branch information...
1 parent c31d43c commit c1a21d3a8d2e9d6e2cc02b3349d9bd4902f09171 @chewbranca chewbranca committed Jan 12, 2012
Showing with 14 additions and 10 deletions.
  1. +14 −10 app/controllers/application_controller.rb
View
24 app/controllers/application_controller.rb
@@ -315,18 +315,22 @@ def update_last_active
last_active = current_user.last_active
current_user.touch(:last_active)
- if current_facebook_user
- unless not Rails.env.development? and last_active and current_user.last_active < last_active + 1.hour
- redis_friends = $redis.smembers "#{current_user.cache_id}:friends"
- unless redis_friends.any? and last_active and current_user.last_active < last_active + 4.hours
- fb_friends = current_facebook_user.facebook_friend_ids
- $redis.set "#{current_facebook_user.cache_id}:friends_string", fb_friends.join(',')
- current_user.redis_update_friends fb_friends.join(',')
+ begin
+ if current_facebook_user
+ unless not Rails.env.development? and last_active and current_user.last_active < last_active + 1.hour
+ redis_friends = $redis.smembers "#{current_user.cache_id}:friends"
+ unless redis_friends.any? and last_active and current_user.last_active < last_active + 4.hours
+ fb_friends = current_facebook_user.facebook_friend_ids
+ $redis.set "#{current_facebook_user.cache_id}:friends_string", fb_friends.join(',')
+ current_user.redis_update_friends fb_friends.join(',')
+ end
+ # Expire recent users
+ Newscloud::Redcloud.expire_sets($redis.keys("#{User.model_deps_key}:*"))
+ else
end
- # Expire recent users
- Newscloud::Redcloud.expire_sets($redis.keys("#{User.model_deps_key}:*"))
- else
end
+ rescue
+ # Just move on if facebook friends request fails
end
end

0 comments on commit c1a21d3

Please sign in to comment.
Something went wrong with that request. Please try again.