Permalink
Browse files

ordering

  • Loading branch information...
root
root committed Jan 10, 2009
1 parent 99d792b commit f8b65db7a961b659ca93aeb8eb2ce4c1e5bbfed6
Showing with 21 additions and 6 deletions.
  1. +21 −6 app/controllers/status_controller.rb
@@ -1,13 +1,19 @@
class StatusController < ApplicationController
ensure_authenticated_to_facebook
+ before_filter :check_session
def index
- @facebook_user = session[:facebook_session].user
- @user = User.find_or_initialize_by_id @facebook_user.id
- @user.save if @user.new_record?
- Delayed::Job.enqueue Job::FetchStatuses.new(@user.id)
- @statuses = @user.statuses + Status.all(:conditions => {:user_id => @facebook_user.friends.map(&:id)})
- @status = Status.new(params[:status])
+ if session[:facebook_session]
+ @facebook_user = session[:facebook_session].user
+ @user = User.find_or_initialize_by_id @facebook_user.id
+ @user.save if @user.new_record?
+ @statuses = @user.statuses + Status.all(:conditions => {:user_id => @facebook_user.friends.map(&:id)})
+ @statuses.sort_by(&:created_at)
+ @statuses.reverse!
+ @status = Status.new(params[:status])
+ else
+ redirect_to '/'
+ end
end
def create
@@ -24,4 +30,13 @@ def create
:next_cancel => root_url(:status => params[:status]))
end
end
+
+ protected
+ def check_session
+ begin
+ session[:facebook_session].user.name
+ rescue Facebooker::Session::SessionExpired
+ session[:facebook_session] = nil
+ end
+ end
end

0 comments on commit f8b65db

Please sign in to comment.