Skip to content
Extraits de code Groupes Projets
Valider e3ad078b rédigé par Raphael Sofaer's avatar Raphael Sofaer
Parcourir les fichiers

Scope querying in PhotosController#show

parent 5fa2a7a6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
......@@ -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 = {})
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter