diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 1e281e7c184d36b7978fae3edb9807b979152132..1291513d160ddb3cce7bcedc52ce0ed3e1adaa79 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -139,7 +139,7 @@ class PhotosController < ApplicationController end def show - @photo = current_user.find_visible_post_by_id(params[:id]) + @photo = current_user.find_visible_post_by_id(params[:id], :type => 'Photo') if @photo @parent = StatusMessage.where(:id => @photo.status_message_id).includes(:photos).first if @photo.status_message_id diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 72df69bddc96f9ceff0b13dd0285516d95256fb9..97f7b32bee44a005b0361b31602ad3614198e90a 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -6,10 +6,10 @@ module Diaspora module UserModules module Querying - 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 + def find_visible_post_by_id( id, opts={} ) + post = Post.where(:id => id).joins(:contacts).where(:contacts => {:user_id => self.id}).where(opts).first + post ||= Post.where(:id => id, :author_id => self.person.id).where(opts).first + post ||= Post.where(:id => id, :public => true).where(opts).first end def raw_visible_posts(opts = {})