don't add public shareables to aspect_visibilities
This commit is contained in:
parent
54ff7ee278
commit
f913128967
6 changed files with 14 additions and 11 deletions
|
|
@ -150,10 +150,12 @@ class PhotosController < ApplicationController
|
||||||
@photo = current_user.build_post(:photo, params[:photo])
|
@photo = current_user.build_post(:photo, params[:photo])
|
||||||
|
|
||||||
if @photo.save
|
if @photo.save
|
||||||
aspects = current_user.aspects_from_ids(params[:photo][:aspect_ids])
|
|
||||||
|
|
||||||
unless @photo.pending
|
unless @photo.pending
|
||||||
current_user.add_to_streams(@photo, aspects)
|
unless @photo.public?
|
||||||
|
aspects = current_user.aspects_from_ids(params[:photo][:aspect_ids])
|
||||||
|
current_user.add_to_streams(@photo, aspects)
|
||||||
|
end
|
||||||
current_user.dispatch_post(@photo, :to => params[:photo][:aspect_ids])
|
current_user.dispatch_post(@photo, :to => params[:photo][:aspect_ids])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ class ResharesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @reshare.save
|
if @reshare.save
|
||||||
current_user.add_to_streams(@reshare, current_user.aspects)
|
|
||||||
current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root_author)
|
current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root_author)
|
||||||
render :json => ExtremePostPresenter.new(@reshare, current_user), :status => 201
|
render :json => ExtremePostPresenter.new(@reshare, current_user), :status => 201
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,10 @@ module User::Querying
|
||||||
query = opts[:klass].where(conditions)
|
query = opts[:klass].where(conditions)
|
||||||
|
|
||||||
unless opts[:all_aspects?]
|
unless opts[:all_aspects?]
|
||||||
query = query.joins(:aspect_visibilities).where(aspect_visibilities: {aspect_id: opts[:by_members_of]})
|
query = query.with_aspects.where(
|
||||||
|
AspectVisibility.arel_table[:aspect_id].in(opts[:by_members_of])
|
||||||
|
.or(opts[:klass].arel_table[:public].eq(true))
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
ugly_select_clause(query, opts)
|
ugly_select_clause(query, opts)
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,9 @@ class StatusMessageCreationService
|
||||||
end
|
end
|
||||||
|
|
||||||
def destination_aspect_ids(params, user)
|
def destination_aspect_ids(params, user)
|
||||||
if params[:status_message][:public] || params[:status_message][:aspect_ids].first == "all_aspects"
|
if params[:status_message][:aspect_ids].first == "all_aspects"
|
||||||
user.aspect_ids
|
user.aspect_ids
|
||||||
else
|
elsif !params[:status_message][:public]
|
||||||
params[:aspect_ids]
|
params[:aspect_ids]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,10 @@ module Diaspora
|
||||||
joins("LEFT OUTER JOIN share_visibilities ON share_visibilities.shareable_id = #{table_name}.id")
|
joins("LEFT OUTER JOIN share_visibilities ON share_visibilities.shareable_id = #{table_name}.id")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :with_aspects, -> {
|
||||||
|
joins("LEFT OUTER JOIN aspect_visibilities ON aspect_visibilities.shareable_id = #{table_name}.id")
|
||||||
|
}
|
||||||
|
|
||||||
def self.owned_or_visible_by_user(user)
|
def self.owned_or_visible_by_user(user)
|
||||||
with_visibility.where(
|
with_visibility.where(
|
||||||
visible_by_user(user).or(arel_table[:public].eq(true)
|
visible_by_user(user).or(arel_table[:public].eq(true)
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,6 @@ describe ResharesController, :type => :controller do
|
||||||
}.to change(Reshare, :count).by(1)
|
}.to change(Reshare, :count).by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'after save, calls add to streams' do
|
|
||||||
expect(bob).to receive(:add_to_streams)
|
|
||||||
post_request!
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'calls dispatch' do
|
it 'calls dispatch' do
|
||||||
expect(bob).to receive(:dispatch_post).with(anything, hash_including(:additional_subscribers))
|
expect(bob).to receive(:dispatch_post).with(anything, hash_including(:additional_subscribers))
|
||||||
post_request!
|
post_request!
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue