From 0c8db5beeed18ce3fc502e55af485a7f9c01c08c Mon Sep 17 00:00:00 2001
From: danielgrippi <daniel@joindiaspora.com>
Date: Tue, 29 Mar 2011 20:17:19 -0700
Subject: [PATCH] Fix find_visible_post_by_id

---
 lib/diaspora/user/querying.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb
index 848e8b0e26..23d560cc47 100644
--- a/lib/diaspora/user/querying.rb
+++ b/lib/diaspora/user/querying.rb
@@ -7,7 +7,8 @@ module Diaspora
     module Querying
 
       def find_visible_post_by_id( id )
-        self.raw_visible_posts.where(:id => id).includes({:author => :profile}, {:comments => {:author => :profile}}, :photos).first
+        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
       end
 
       def raw_visible_posts(opts = {})
-- 
GitLab