Hide local statuses from user atom and from unlogged users

This commit is contained in:
Renato "Lond" Cerqueira 2018-09-03 21:47:07 +02:00
parent 6bef1a8134
commit 469294d293
2 changed files with 7 additions and 2 deletions

View File

@ -30,7 +30,7 @@ class AccountsController < ApplicationController
end end
format.atom do format.atom do
@entries = @account.stream_entries.where(hidden: false).with_includes.paginate_by_max_id(PAGE_SIZE, params[:max_id], params[:since_id]) @entries = @account.stream_entries.where(hidden: false).with_includes.without_local_only.paginate_by_max_id(PAGE_SIZE, params[:max_id], params[:since_id])
render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.reject { |entry| entry.status.nil? })) render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.feed(@account, @entries.reject { |entry| entry.status.nil? }))
end end
@ -63,7 +63,11 @@ class AccountsController < ApplicationController
end end
def default_statuses def default_statuses
@account.statuses.where(visibility: [:public, :unlisted]) if current_user.nil?
@account.statuses.without_local_only.where(visibility: [:public, :unlisted])
else
@account.statuses.where(visibility: [:public, :unlisted])
end
end end
def only_media_scope def only_media_scope

View File

@ -26,6 +26,7 @@ class StreamEntry < ApplicationRecord
default_scope { where(activity_type: 'Status') } default_scope { where(activity_type: 'Status') }
scope :recent, -> { reorder(id: :desc) } scope :recent, -> { reorder(id: :desc) }
scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) } scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) }
scope :without_local_only, -> { where(statuses: { local_only: [false, nil] }) }
delegate :target, :title, :content, :thread, :local_only?, delegate :target, :title, :content, :thread, :local_only?,
to: :status, to: :status,