Fix PhotosController#show

This commit is contained in:
Raphael Sofaer 2011-03-30 15:43:10 -07:00
parent 66a52a49d6
commit 8c9a7e1c41
2 changed files with 3 additions and 3 deletions

View file

@ -139,8 +139,7 @@ class PhotosController < ApplicationController
end
def show
@photo = current_user.visible_photos.where(:id => params[:id]).first
@photo ||= Photo.where(:public => true, :id => params[:id]).first
@photo = current_user.find_visible_post_by_id(params[:id])
if @photo
@parent = StatusMessage.where(:id => @photo.status_message_id).includes(:photos).first if @photo.status_message_id

View file

@ -9,6 +9,7 @@ module Diaspora
def find_visible_post_by_id( id )
post = Post.where(:id => id).joins(:contacts).where(:contacts => {:user_id => self.id}).first
post ||= Post.where(:id => id, :author_id => self.person.id).first
post ||= Post.where(:id => id, :public => true).first
end
def raw_visible_posts(opts = {})
@ -26,7 +27,7 @@ module Diaspora
:aspect_memberships => {:aspect_id => opts[:by_members_of]})
posts_from_self = posts_from_self.where(:aspects => {:id => opts[:by_members_of]})
end
post_ids = Post.connection.execute(posts_from_others.select('posts.id').limit(opts[:limit]).order(opts[:order]).to_sql).map{|r| r.first}
post_ids += Post.connection.execute(posts_from_self.select('posts.id').limit(opts[:limit]).order(opts[:order]).to_sql).map{|r| r.first}