From 469294d2939669ec8acbfaa10a03993bdb178298 Mon Sep 17 00:00:00 2001 From: "Renato \"Lond\" Cerqueira" Date: Mon, 3 Sep 2018 21:47:07 +0200 Subject: [PATCH] Hide local statuses from user atom and from unlogged users --- app/controllers/accounts_controller.rb | 8 ++++++-- app/models/stream_entry.rb | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 52753c1c3..58f4f100d 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -30,7 +30,7 @@ class AccountsController < ApplicationController end 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? })) end @@ -63,7 +63,11 @@ class AccountsController < ApplicationController end 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 def only_media_scope diff --git a/app/models/stream_entry.rb b/app/models/stream_entry.rb index dd383eb81..0747300d4 100644 --- a/app/models/stream_entry.rb +++ b/app/models/stream_entry.rb @@ -26,6 +26,7 @@ class StreamEntry < ApplicationRecord default_scope { where(activity_type: 'Status') } scope :recent, -> { reorder(id: :desc) } 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?, to: :status,